Skip to content

Commit efe6060

Browse files
committed
Merge branch 'DimitriPapadopoulos-pyupgrade'
2 parents ec7d5b6 + 5b1b511 commit efe6060

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

ez_setup.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def _build_egg(egg, archive_filename, to_dir):
7575
# returning the result
7676
log.warn(egg)
7777
if not os.path.exists(egg):
78-
raise IOError('Could not build the egg.')
78+
raise OSError('Could not build the egg.')
7979

8080

8181
class ContextualZipFile(zipfile.ZipFile):
@@ -92,7 +92,7 @@ def __new__(cls, *args, **kwargs):
9292
"""Construct a ZipFile or ContextualZipFile as appropriate."""
9393
if hasattr(zipfile.ZipFile, '__exit__'):
9494
return zipfile.ZipFile(*args, **kwargs)
95-
return super(ContextualZipFile, cls).__new__(cls)
95+
return super().__new__(cls)
9696

9797

9898
@contextlib.contextmanager
@@ -131,7 +131,7 @@ def archive_context(filename):
131131

132132
def _do_download(version, download_base, to_dir, download_delay):
133133
"""Download Setuptools."""
134-
py_desig = 'py{sys.version_info[0]}.{sys.version_info[1]}'.format(sys=sys)
134+
py_desig = f'py{sys.version_info[0]}.{sys.version_info[1]}'
135135
tp = f'setuptools-{version}-{py_desig}.egg'
136136
egg = os.path.join(to_dir, tp.format(**locals()))
137137
if not os.path.exists(egg):
@@ -245,8 +245,7 @@ def download_file_powershell(url, target):
245245
ps_cmd = (
246246
"[System.Net.WebRequest]::DefaultWebProxy.Credentials = "
247247
"[System.Net.CredentialCache]::DefaultCredentials; "
248-
'(new-object System.Net.WebClient).DownloadFile("%(url)s", "%(target)s")'
249-
% locals()
248+
'(new-object System.Net.WebClient).DownloadFile("{url}", "{target}")'.format(**locals())
250249
)
251250
cmd = [
252251
'powershell',
@@ -346,7 +345,7 @@ def download_setuptools(
346345
"""
347346
# making sure we use the absolute path
348347
to_dir = os.path.abspath(to_dir)
349-
zip_name = "setuptools-%s.zip" % version
348+
zip_name = f"setuptools-{version}.zip"
350349
url = download_base + zip_name
351350
saveto = os.path.join(to_dir, zip_name)
352351
if not os.path.exists(saveto): # Avoid repeated downloads

tests/test_dicttoxml.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ def test_non_string_attr(self):
191191
self.assertEqual('<a attr="1"></a>', _strip(unparse(obj)))
192192

193193
def test_short_empty_elements(self):
194-
if sys.version_info[0] < 3:
195-
return
196194
obj = {'a': None}
197195
self.assertEqual('<a/>', _strip(unparse(obj, short_empty_elements=True)))
198196

tests/test_xmltodict.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ def test_unicode(self):
168168
except NameError:
169169
value = chr(39321)
170170
self.assertEqual({'a': value},
171-
parse('<a>%s</a>' % value))
171+
parse(f'<a>{value}</a>'))
172172

173173
def test_encoded_string(self):
174174
try:
175175
value = unichr(39321)
176176
except NameError:
177177
value = chr(39321)
178-
xml = '<a>%s</a>' % value
178+
xml = f'<a>{value}</a>'
179179
self.assertEqual(parse(xml),
180180
parse(xml.encode('utf-8')))
181181

xmltodict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def _emit(key, value, content_handler,
422422
attr_prefix)
423423
if ik == '@xmlns' and isinstance(iv, dict):
424424
for k, v in iv.items():
425-
attr = 'xmlns{}'.format(':{}'.format(k) if k else '')
425+
attr = 'xmlns{}'.format(f':{k}' if k else '')
426426
attrs[attr] = str(v)
427427
continue
428428
if not isinstance(iv, str):

0 commit comments

Comments
 (0)