Skip to content

Commit 7f70d7d

Browse files
committed
👹 Feed the hobgoblins (delint).
Ran `ruff --format` on the code.
1 parent 1bd78d0 commit 7f70d7d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+181
-164
lines changed

‎conftest.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212

1313

1414
if platform.system() != 'Windows':
15-
collect_ignore.extend(
16-
[
17-
'distutils/msvc9compiler.py',
18-
]
19-
)
15+
collect_ignore.extend([
16+
'distutils/msvc9compiler.py',
17+
])
2018

2119

2220
@pytest.fixture

‎distutils/bcppcompiler.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
# someone should sit down and factor out the common code as
1212
# WindowsCCompiler! --GPW
1313

14-
1514
import os
1615
import warnings
1716

‎distutils/ccompiler.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,11 @@ def executable_filename(self, basename, strip_dir=0, output_dir=''):
10041004
return os.path.join(output_dir, basename + (self.exe_extension or ''))
10051005

10061006
def library_filename(
1007-
self, libname, lib_type='static', strip_dir=0, output_dir='' # or 'shared'
1007+
self,
1008+
libname,
1009+
lib_type='static',
1010+
strip_dir=0,
1011+
output_dir='', # or 'shared'
10081012
):
10091013
assert output_dir is not None
10101014
expected = '"static", "shared", "dylib", "xcode_stub"'

‎distutils/command/_framework_compat.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Backward compatibility for homebrew builds on macOS.
33
"""
44

5-
65
import sys
76
import os
87
import functools

‎distutils/command/bdist.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,15 @@ class bdist(Command):
7676
default_format = {'posix': 'gztar', 'nt': 'zip'}
7777

7878
# Define commands in preferred order for the --help-formats option
79-
format_commands = ListCompat(
80-
{
81-
'rpm': ('bdist_rpm', "RPM distribution"),
82-
'gztar': ('bdist_dumb', "gzip'ed tar file"),
83-
'bztar': ('bdist_dumb', "bzip2'ed tar file"),
84-
'xztar': ('bdist_dumb', "xz'ed tar file"),
85-
'ztar': ('bdist_dumb', "compressed tar file"),
86-
'tar': ('bdist_dumb', "tar file"),
87-
'zip': ('bdist_dumb', "ZIP file"),
88-
}
89-
)
79+
format_commands = ListCompat({
80+
'rpm': ('bdist_rpm', "RPM distribution"),
81+
'gztar': ('bdist_dumb', "gzip'ed tar file"),
82+
'bztar': ('bdist_dumb', "bzip2'ed tar file"),
83+
'xztar': ('bdist_dumb', "xz'ed tar file"),
84+
'ztar': ('bdist_dumb', "compressed tar file"),
85+
'tar': ('bdist_dumb', "tar file"),
86+
'zip': ('bdist_dumb', "ZIP file"),
87+
})
9088

9189
# for compatibility until consumers only reference format_commands
9290
format_command = format_commands

‎distutils/command/bdist_rpm.py

+37-47
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,11 @@ def run(self): # noqa: C901
401401
if os.path.exists(rpm):
402402
self.move_file(rpm, self.dist_dir)
403403
filename = os.path.join(self.dist_dir, os.path.basename(rpm))
404-
self.distribution.dist_files.append(
405-
('bdist_rpm', pyversion, filename)
406-
)
404+
self.distribution.dist_files.append((
405+
'bdist_rpm',
406+
pyversion,
407+
filename,
408+
))
407409

408410
def _dist_path(self, path):
409411
return os.path.join(self.dist_dir, os.path.basename(path))
@@ -428,9 +430,9 @@ def _make_spec_file(self): # noqa: C901
428430
# Generate a potential replacement value for __os_install_post (whilst
429431
# normalizing the whitespace to simplify the test for whether the
430432
# invocation of brp-python-bytecompile passes in __python):
431-
vendor_hook = '\n'.join(
432-
[' %s \\' % line.strip() for line in vendor_hook.splitlines()]
433-
)
433+
vendor_hook = '\n'.join([
434+
' %s \\' % line.strip() for line in vendor_hook.splitlines()
435+
])
434436
problem = "brp-python-bytecompile \\\n"
435437
fixed = "brp-python-bytecompile %{__python} \\\n"
436438
fixed_hook = vendor_hook.replace(problem, fixed)
@@ -445,13 +447,11 @@ def _make_spec_file(self): # noqa: C901
445447
# spec_file.append('Summary(%s): %s' % (locale,
446448
# self.summaries[locale]))
447449

448-
spec_file.extend(
449-
[
450-
'Name: %{name}',
451-
'Version: %{version}',
452-
'Release: %{release}',
453-
]
454-
)
450+
spec_file.extend([
451+
'Name: %{name}',
452+
'Version: %{version}',
453+
'Release: %{release}',
454+
])
455455

456456
# XXX yuck! this filename is available from the "sdist" command,
457457
# but only after it has run: and we create the spec file before
@@ -461,14 +461,12 @@ def _make_spec_file(self): # noqa: C901
461461
else:
462462
spec_file.append('Source0: %{name}-%{unmangled_version}.tar.gz')
463463

464-
spec_file.extend(
465-
[
466-
'License: ' + (self.distribution.get_license() or "UNKNOWN"),
467-
'Group: ' + self.group,
468-
'BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot',
469-
'Prefix: %{_prefix}',
470-
]
471-
)
464+
spec_file.extend([
465+
'License: ' + (self.distribution.get_license() or "UNKNOWN"),
466+
'Group: ' + self.group,
467+
'BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot',
468+
'Prefix: %{_prefix}',
469+
])
472470

473471
if not self.force_arch:
474472
# noarch if no extension modules
@@ -506,13 +504,11 @@ def _make_spec_file(self): # noqa: C901
506504
if self.no_autoreq:
507505
spec_file.append('AutoReq: 0')
508506

509-
spec_file.extend(
510-
[
511-
'',
512-
'%description',
513-
self.distribution.get_long_description() or "",
514-
]
515-
)
507+
spec_file.extend([
508+
'',
509+
'%description',
510+
self.distribution.get_long_description() or "",
511+
])
516512

517513
# put locale descriptions into spec file
518514
# XXX again, suppressed because config file syntax doesn't
@@ -558,37 +554,31 @@ def _make_spec_file(self): # noqa: C901
558554
# use 'default' as contents of script
559555
val = getattr(self, attr)
560556
if val or default:
561-
spec_file.extend(
562-
[
563-
'',
564-
'%' + rpm_opt,
565-
]
566-
)
557+
spec_file.extend([
558+
'',
559+
'%' + rpm_opt,
560+
])
567561
if val:
568562
with open(val) as f:
569563
spec_file.extend(f.read().split('\n'))
570564
else:
571565
spec_file.append(default)
572566

573567
# files section
574-
spec_file.extend(
575-
[
576-
'',
577-
'%files -f INSTALLED_FILES',
578-
'%defattr(-,root,root)',
579-
]
580-
)
568+
spec_file.extend([
569+
'',
570+
'%files -f INSTALLED_FILES',
571+
'%defattr(-,root,root)',
572+
])
581573

582574
if self.doc_files:
583575
spec_file.append('%doc ' + ' '.join(self.doc_files))
584576

585577
if self.changelog:
586-
spec_file.extend(
587-
[
588-
'',
589-
'%changelog',
590-
]
591-
)
578+
spec_file.extend([
579+
'',
580+
'%changelog',
581+
])
592582
spec_file.extend(self.changelog)
593583

594584
return spec_file

‎distutils/command/build_py.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def find_data_files(self, package, src_dir):
129129
os.path.join(glob.escape(src_dir), convert_path(pattern))
130130
)
131131
# Files that match more than one pattern are only added once
132-
files.extend(
133-
[fn for fn in filelist if fn not in files and os.path.isfile(fn)]
134-
)
132+
files.extend([
133+
fn for fn in filelist if fn not in files and os.path.isfile(fn)
134+
])
135135
return files
136136

137137
def build_package_data(self):

‎distutils/command/check.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Implements the Distutils 'check' command.
44
"""
5+
56
import contextlib
67

78
from ..core import Command
@@ -144,8 +145,11 @@ def _check_rst_data(self, data):
144145
try:
145146
parser.parse(data, document)
146147
except AttributeError as e:
147-
reporter.messages.append(
148-
(-1, 'Could not finish the parsing: %s.' % e, '', {})
149-
)
148+
reporter.messages.append((
149+
-1,
150+
'Could not finish the parsing: %s.' % e,
151+
'',
152+
{},
153+
))
150154

151155
return reporter.messages

‎distutils/command/install.py

+19-16
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,11 @@ class install(Command):
245245
boolean_options = ['compile', 'force', 'skip-build']
246246

247247
if HAS_USER_SITE:
248-
user_options.append(
249-
('user', None, "install in user site-package '%s'" % USER_SITE)
250-
)
248+
user_options.append((
249+
'user',
250+
None,
251+
"install in user site-package '%s'" % USER_SITE,
252+
))
251253
boolean_options.append('user')
252254

253255
negative_opt = {'no-compile': 'compile'}
@@ -432,9 +434,12 @@ def finalize_options(self): # noqa: C901
432434
local_vars['userbase'] = self.install_userbase
433435
local_vars['usersite'] = self.install_usersite
434436

435-
self.config_vars = _collections.DictStack(
436-
[fw.vars(), compat_vars, sysconfig.get_config_vars(), local_vars]
437-
)
437+
self.config_vars = _collections.DictStack([
438+
fw.vars(),
439+
compat_vars,
440+
sysconfig.get_config_vars(),
441+
local_vars,
442+
])
438443

439444
self.expand_basedirs()
440445

@@ -620,16 +625,14 @@ def expand_basedirs(self):
620625

621626
def expand_dirs(self):
622627
"""Calls `os.path.expanduser` on install dirs."""
623-
self._expand_attrs(
624-
[
625-
'install_purelib',
626-
'install_platlib',
627-
'install_lib',
628-
'install_headers',
629-
'install_scripts',
630-
'install_data',
631-
]
632-
)
628+
self._expand_attrs([
629+
'install_purelib',
630+
'install_platlib',
631+
'install_lib',
632+
'install_headers',
633+
'install_scripts',
634+
'install_data',
635+
])
633636

634637
def convert_paths(self, *names):
635638
"""Call `convert_path` over `names`."""

‎distutils/command/register.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def check_metadata(self):
7777
check.run()
7878

7979
def _set_config(self):
80-
'''Reads the configuration file and set attributes.'''
80+
"""Reads the configuration file and set attributes."""
8181
config = self._read_pypirc()
8282
if config != {}:
8383
self.username = config['username']
@@ -93,19 +93,19 @@ def _set_config(self):
9393
self.has_config = False
9494

9595
def classifiers(self):
96-
'''Fetch the list of classifiers from the server.'''
96+
"""Fetch the list of classifiers from the server."""
9797
url = self.repository + '?:action=list_classifiers'
9898
response = urllib.request.urlopen(url)
9999
log.info(self._read_pypi_response(response))
100100

101101
def verify_metadata(self):
102-
'''Send the metadata to the package index server to be checked.'''
102+
"""Send the metadata to the package index server to be checked."""
103103
# send the info to the server and report the result
104104
(code, result) = self.post_to_server(self.build_post_data('verify'))
105105
log.info('Server response (%s): %s', code, result)
106106

107107
def send_metadata(self): # noqa: C901
108-
'''Send the metadata to the package index server.
108+
"""Send the metadata to the package index server.
109109
110110
Well, do the following:
111111
1. figure who the user is, and then
@@ -131,7 +131,7 @@ def send_metadata(self): # noqa: C901
131131
2. register as a new user, or
132132
3. set the password to a random string and email the user.
133133
134-
'''
134+
"""
135135
# see if we can short-cut and get the username/password from the
136136
# config
137137
if self.has_config:
@@ -146,13 +146,13 @@ def send_metadata(self): # noqa: C901
146146
choices = '1 2 3 4'.split()
147147
while choice not in choices:
148148
self.announce(
149-
'''\
149+
"""\
150150
We need to know who you are, so please choose either:
151151
1. use your existing login,
152152
2. register as a new user,
153153
3. have the server generate a new password for you (and email it to you), or
154154
4. quit
155-
Your selection [default 1]: ''',
155+
Your selection [default 1]: """,
156156
logging.INFO,
157157
)
158158
choice = input()
@@ -262,7 +262,7 @@ def build_post_data(self, action):
262262
return data
263263

264264
def post_to_server(self, data, auth=None): # noqa: C901
265-
'''Post a query to the server, and return a string response.'''
265+
"""Post a query to the server, and return a string response."""
266266
if 'name' in data:
267267
self.announce(
268268
'Registering {} to {}'.format(data['name'], self.repository),

‎distutils/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Provides the PyPIRCCommand class, the base class for the command classes
44
that uses .pypirc in the distutils.command package.
55
"""
6+
67
import os
78
from configparser import RawConfigParser
89

‎distutils/cygwinccompiler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def check_config_h():
344344

345345

346346
def is_cygwincc(cc):
347-
'''Try to determine if the compiler that would be used is from cygwin.'''
347+
"""Try to determine if the compiler that would be used is from cygwin."""
348348
out_string = check_output(shlex.split(cc) + ['-dumpmachine'])
349349
return out_string.strip().endswith(b'cygwin')
350350

‎distutils/extension.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def __init__(
102102
depends=None,
103103
language=None,
104104
optional=None,
105-
**kw # To catch unknown keywords
105+
**kw, # To catch unknown keywords
106106
):
107107
if not isinstance(name, str):
108108
raise AssertionError("'name' must be a string")

0 commit comments

Comments
 (0)