From 172fe8d4c63b0efb6dcfcdc1f12b86634411008f Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Fri, 28 Jun 2024 20:28:05 +0200 Subject: [PATCH] A round of `ruff format` after `ruff check --fix` --- setuptools/command/bdist_egg.py | 4 +++- setuptools/command/easy_install.py | 16 ++++++++++++---- setuptools/command/egg_info.py | 4 +++- setuptools/command/install_egg_info.py | 4 +++- setuptools/dist.py | 20 +++++++++++++++----- setuptools/msvc.py | 7 +++++-- setuptools/package_index.py | 5 +++-- setuptools/tests/test_manifest.py | 4 +--- setuptools/tests/test_sdist.py | 4 +--- setuptools/wheel.py | 4 +++- 10 files changed, 49 insertions(+), 23 deletions(-) diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 3276c102a43..e7cd3fa5dcb 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -253,7 +253,9 @@ def zap_pyfiles(self): pattern = r'(?P.+)\.(?P[^.]+)\.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: diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 76ce22ef6f9..2a85a63cf8e 100644 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -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 @@ -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] @@ -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) diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 6d24f18348d..3f32af2435f 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -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: diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index 70b2cb35c19..f887e43d552 100644 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -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): diff --git a/setuptools/dist.py b/setuptools/dist.py index 21da587e2cb..fc09cdc676e 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -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 @@ -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 @@ -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" @@ -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): diff --git a/setuptools/msvc.py b/setuptools/msvc.py index 676d4f45e0b..ce3843dc749 100644 --- a/setuptools/msvc.py +++ b/setuptools/msvc.py @@ -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 @@ -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 '' diff --git a/setuptools/package_index.py b/setuptools/package_index.py index cf824e9e6fe..a2744696290 100644 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -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): diff --git a/setuptools/tests/test_manifest.py b/setuptools/tests/test_manifest.py index f48dd6882cc..98c5cf9f5ac 100644 --- a/setuptools/tests/test_manifest.py +++ b/setuptools/tests/test_manifest.py @@ -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 diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 493fe34e034..d8ef4c66961 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -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", diff --git a/setuptools/wheel.py b/setuptools/wheel.py index f49a4ce7a89..130eecbd52b 100644 --- a/setuptools/wheel.py +++ b/setuptools/wheel.py @@ -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.