Skip to content

Commit 2661eea

Browse files
authored
Modernize Python syntax using pyupgrade --py36-plus (#278)
* Modernize Python syntax using `pyupgrade --py36-plus` * Fix flake8 reported issue
1 parent 7ca5a84 commit 2661eea

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

auditwheel/condatools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ def __enter__(self):
2929

3030
def iter_files(self):
3131
files = os.path.join(self.path, 'info', 'files')
32-
with open(files, 'rt') as f:
32+
with open(files) as f:
3333
return [line.strip() for line in f.readlines()]

auditwheel/lddtree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def parse_ld_so_conf(ldso_conf: str,
154154
_first=False)
155155
else:
156156
paths += [normpath(root + line)]
157-
except IOError as e:
157+
except OSError as e:
158158
if e.errno != errno.ENOENT:
159159
log.warning(e)
160160

auditwheel/main_show.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,29 @@ def execute(args, p):
3636
logger.info('This does not look like a platform wheel')
3737
return 1
3838

39-
libs_with_versions = ['%s with versions %s' % (k, v)
39+
libs_with_versions = [f'{k} with versions {v}'
4040
for k, v in winfo.versioned_symbols.items()]
4141

4242
printp('%s is consistent with the following platform tag: "%s".' %
4343
(fn, winfo.overall_tag))
4444

4545
if get_priority_by_name(winfo.pyfpe_tag) < POLICY_PRIORITY_HIGHEST:
46-
printp(('This wheel uses the PyFPE_jbuf function, which is not '
47-
'compatible with the manylinux1 tag. (see '
48-
'https://www.python.org/dev/peps/pep-0513/#fpectl-builds-vs-no-fpectl-builds)')) # noqa
46+
printp('This wheel uses the PyFPE_jbuf function, which is not '
47+
'compatible with the manylinux1 tag. (see '
48+
'https://www.python.org/dev/peps/pep-0513/#fpectl-builds-vs-no-fpectl-builds)') # noqa
4949
if args.verbose < 1:
5050
return
5151

5252
if get_priority_by_name(winfo.ucs_tag) < POLICY_PRIORITY_HIGHEST:
53-
printp(('This wheel is compiled against a narrow unicode (UCS2) '
54-
'version of Python, which is not compatible with the '
55-
'manylinux1 tag.'))
53+
printp('This wheel is compiled against a narrow unicode (UCS2) '
54+
'version of Python, which is not compatible with the '
55+
'manylinux1 tag.')
5656
if args.verbose < 1:
5757
return
5858

5959
if len(libs_with_versions) == 0:
60-
printp(("The wheel references no external versioned symbols from "
61-
"system-provided shared libraries."))
60+
printp('The wheel references no external versioned symbols from '
61+
'system-provided shared libraries.')
6262
else:
6363
printp('The wheel references external versioned symbols in these '
6464
'system-provided shared libraries: %s' %
@@ -77,8 +77,8 @@ def execute(args, p):
7777
if len(libs) == 0:
7878
printp('The wheel requires no external shared libraries! :)')
7979
else:
80-
printp(('The following external shared libraries are required '
81-
'by the wheel:'))
80+
printp('The following external shared libraries are required '
81+
'by the wheel:')
8282
print(json.dumps(OrderedDict(sorted(libs.items())), indent=4))
8383

8484
for p in sorted(load_policies(), key=lambda p: p['priority']):

auditwheel/repair.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def copylib(src_path, dest_dir, patcher):
124124
src_name = os.path.basename(src_path)
125125
base, ext = src_name.split('.', 1)
126126
if not base.endswith('-%s' % shorthash):
127-
new_soname = '%s-%s.%s' % (base, shorthash, ext)
127+
new_soname = f'{base}-{shorthash}.{ext}'
128128
else:
129129
new_soname = src_name
130130

auditwheel/tmpdirs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from tempfile import TemporaryDirectory
55

66

7-
class InTemporaryDirectory(object):
7+
class InTemporaryDirectory:
88
''' Create, return, and change directory to a temporary directory
99
1010
Examples

auditwheel/wheeltools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ def iter_files(self):
166166
if len(record_names) != 1:
167167
raise ValueError("Should be exactly one `*.dist_info` directory")
168168

169-
with open(record_names[0], 'rt') as f:
169+
with open(record_names[0]) as f:
170170
record = f.read()
171-
reader = csv.reader((r for r in record.splitlines()))
171+
reader = csv.reader(r for r in record.splitlines())
172172
for row in reader:
173173
filename = row[0]
174174
yield filename

0 commit comments

Comments
 (0)