Skip to content

Commit

Permalink
A round of ruff format after ruff check --fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Jun 28, 2024
1 parent c835f6c commit 6347575
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 23 deletions.
4 changes: 3 additions & 1 deletion setuptools/command/bdist_egg.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,9 @@ def zap_pyfiles(self):
pattern = r'(?P<name>.+)\.(?P<magic>[^.]+)\.pyc'
m = re.match(pattern, name)
path_new = os.path.join(base, os.pardir, m.group('name') + '.pyc')
log.info("Renaming file from [{}] to [{}]".format(path_old, path_new))
log.info(
"Renaming file from [{}] to [{}]".format(path_old, path_new)
)
try:
os.remove(path_new)
except OSError:
Expand Down
16 changes: 12 additions & 4 deletions setuptools/command/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,9 @@ def check_editable(self, spec):

if os.path.exists(os.path.join(self.build_directory, spec.key)):
raise DistutilsArgError(
"{!r} already exists in {}; can't do a checkout there".format(spec.key, self.build_directory)
"{!r} already exists in {}; can't do a checkout there".format(
spec.key, self.build_directory
)
)

@contextlib.contextmanager
Expand Down Expand Up @@ -914,11 +916,15 @@ def install_eggs(self, spec, dist_filename, tmpdir):
setups = glob(os.path.join(setup_base, '*', 'setup.py'))
if not setups:
raise DistutilsError(
"Couldn't find a setup script in {}".format(os.path.abspath(dist_filename))
"Couldn't find a setup script in {}".format(
os.path.abspath(dist_filename)
)
)
if len(setups) > 1:
raise DistutilsError(
"Multiple setup scripts in {}".format(os.path.abspath(dist_filename))
"Multiple setup scripts in {}".format(
os.path.abspath(dist_filename)
)
)
setup_script = setups[0]

Expand Down Expand Up @@ -1110,7 +1116,9 @@ def install_wheel(self, wheel_path, tmpdir):
self.execute(
wheel.install_as_egg,
(destination,),
("Installing {} to {}").format(os.path.basename(wheel_path), os.path.dirname(destination)),
("Installing {} to {}").format(
os.path.basename(wheel_path), os.path.dirname(destination)
),
)
finally:
update_dist_caches(destination, fix_zipimporter_caches=False)
Expand Down
4 changes: 3 additions & 1 deletion setuptools/command/egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ def finalize_options(self):
packaging.requirements.Requirement(spec % (self.egg_name, self.egg_version))
except ValueError as e:
raise distutils.errors.DistutilsOptionError(
"Invalid distribution name or version syntax: {}-{}".format(self.egg_name, self.egg_version)
"Invalid distribution name or version syntax: {}-{}".format(
self.egg_name, self.egg_version
)
) from e

if self.egg_base is None:
Expand Down
4 changes: 3 additions & 1 deletion setuptools/command/install_egg_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def run(self):
self.execute(os.unlink, (self.target,), "Removing " + self.target)
if not self.dry_run:
ensure_directory(self.target)
self.execute(self.copytree, (), "Copying {} to {}".format(self.source, self.target))
self.execute(
self.copytree, (), "Copying {} to {}".format(self.source, self.target)
)
self.install_namespaces()

def get_outputs(self):
Expand Down
20 changes: 15 additions & 5 deletions setuptools/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def check_importable(dist, attr, value):
assert not ep.extras
except (TypeError, ValueError, AttributeError, AssertionError) as e:
raise DistutilsSetupError(
"{!r} must be importable 'module:attrs' string (got {!r})".format(attr, value)
"{!r} must be importable 'module:attrs' string (got {!r})".format(
attr, value
)
) from e


Expand Down Expand Up @@ -601,7 +603,9 @@ def _set_command_options(self, command_obj, option_dict=None): # noqa: C901
setattr(command_obj, option, value)
else:
raise DistutilsOptionError(
"error in {}: command '{}' has no such option '{}'".format(source, command_name, option)
"error in {}: command '{}' has no such option '{}'".format(
source, command_name, option
)
)
except ValueError as e:
raise DistutilsOptionError(e) from e
Expand Down Expand Up @@ -801,7 +805,9 @@ def _exclude_misc(self, name, value):
try:
old = getattr(self, name)
except AttributeError as e:
raise DistutilsSetupError("{}: No such distribution setting".format(name)) from e
raise DistutilsSetupError(
"{}: No such distribution setting".format(name)
) from e
if old is not None and not isinstance(old, sequence):
raise DistutilsSetupError(
name + ": this setting cannot be changed via include/exclude"
Expand All @@ -813,11 +819,15 @@ def _include_misc(self, name, value):
"""Handle 'include()' for list/tuple attrs without a special handler"""

if not isinstance(value, sequence):
raise DistutilsSetupError("{}: setting must be a list ({!r})".format(name, value))
raise DistutilsSetupError(
"{}: setting must be a list ({!r})".format(name, value)
)
try:
old = getattr(self, name)
except AttributeError as e:
raise DistutilsSetupError("{}: No such distribution setting".format(name)) from e
raise DistutilsSetupError(
"{}: No such distribution setting".format(name)
) from e
if old is None:
setattr(self, name, value)
elif not isinstance(old, sequence):
Expand Down
7 changes: 5 additions & 2 deletions setuptools/msvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,8 @@ def _guess_vc_legacy(self):
path
"""
default = join(
self.ProgramFilesx86, r'Microsoft Visual Studio {:0.1f}\VC'.format(self.vs_ver)
self.ProgramFilesx86,
r'Microsoft Visual Studio {:0.1f}\VC'.format(self.vs_ver),
)

# Try to get "VC++ for Python" path from registry as default path
Expand Down Expand Up @@ -950,7 +951,9 @@ def UniversalCRTSdkDir(self):

# Find path of the more recent Kit
for ver in vers:
sdkdir = self.ri.lookup(self.ri.windows_kits_roots, 'kitsroot{}'.format(ver))
sdkdir = self.ri.lookup(
self.ri.windows_kits_roots, 'kitsroot{}'.format(ver)
)
if sdkdir:
return sdkdir or ''

Expand Down
5 changes: 3 additions & 2 deletions setuptools/package_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,9 @@ def check_hash(self, checker, filename, tfp):
tfp.close()
os.unlink(filename)
raise DistutilsError(
"{} validation failed for {}; "
"possible download problem?".format(checker.hash.name, os.path.basename(filename))
"{} validation failed for {}; " "possible download problem?".format(
checker.hash.name, os.path.basename(filename)
)
)

def add_find_links(self, urls):
Expand Down
4 changes: 1 addition & 3 deletions setuptools/tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ def make_local_path(s):
'packages': ['app'],
}

SETUP_PY = (
"""\
SETUP_PY = """\
from setuptools import setup
setup(**{!r})
""".format(SETUP_ATTRS)
)


@contextlib.contextmanager
Expand Down
4 changes: 1 addition & 3 deletions setuptools/tests/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@
'data_files': [("data", [os.path.join("d", "e.dat")])],
}

SETUP_PY = (
"""\
SETUP_PY = """\
from setuptools import setup
setup(**{!r})
""".format(SETUP_ATTRS)
)

EXTENSION = Extension(
name="sdist_test.f",
Expand Down
4 changes: 3 additions & 1 deletion setuptools/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ def get_metadata(name):
wheel_version = parse_version(wheel_metadata.get('Wheel-Version'))
wheel_v1 = parse_version('1.0') <= wheel_version < parse_version('2.0dev0')
if not wheel_v1:
raise ValueError('unsupported wheel format version: {}'.format(wheel_version))
raise ValueError(
'unsupported wheel format version: {}'.format(wheel_version)
)
# Extract to target directory.
_unpack_zipfile_obj(zf, destination_eggdir)
# Convert metadata.
Expand Down

0 comments on commit 6347575

Please sign in to comment.