From 1f92af5201ebffcf4c7107f9d9dfcc687e57e2cc Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 25 Oct 2024 17:17:41 +0100 Subject: [PATCH 1/2] Sync pre-commit-hook with version of ruff that gets automatically pulled in tests --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a88677f50c..04870d16bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.7 + rev: v0.7.1 hooks: - id: ruff args: [--fix, --unsafe-fixes] From c498d162e7501165fb8415fec4ed3282b2f04af9 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 25 Oct 2024 17:54:35 +0100 Subject: [PATCH 2/2] Satisfy ruff linter - automatic fix --- setuptools/command/alias.py | 3 +-- setuptools/command/bdist_wheel.py | 6 +++--- setuptools/command/install.py | 3 +-- setuptools/tests/config/test_setupcfg.py | 4 +--- setuptools/tests/test_build_py.py | 12 +++++------ setuptools/tests/test_easy_install.py | 27 ++++++++++++------------ 6 files changed, 25 insertions(+), 30 deletions(-) diff --git a/setuptools/command/alias.py b/setuptools/command/alias.py index 4eed652381..3111d26496 100644 --- a/setuptools/command/alias.py +++ b/setuptools/command/alias.py @@ -34,8 +34,7 @@ def finalize_options(self): option_base.finalize_options(self) if self.remove and len(self.args) != 1: raise DistutilsOptionError( - "Must specify exactly one argument (the alias name) when " - "using --remove" + "Must specify exactly one argument (the alias name) when using --remove" ) def run(self): diff --git a/setuptools/command/bdist_wheel.py b/setuptools/command/bdist_wheel.py index aeade98f6f..f377cd5ee6 100644 --- a/setuptools/command/bdist_wheel.py +++ b/setuptools/command/bdist_wheel.py @@ -390,9 +390,9 @@ def get_tag(self) -> tuple[str, str, str]: supported_tags = [ (t.interpreter, t.abi, plat_name) for t in tags.sys_tags() ] - assert ( - tag in supported_tags - ), f"would build wheel with unsupported tag {tag}" + assert tag in supported_tags, ( + f"would build wheel with unsupported tag {tag}" + ) return tag def run(self): diff --git a/setuptools/command/install.py b/setuptools/command/install.py index e2ec1abdde..e1dff0aac7 100644 --- a/setuptools/command/install.py +++ b/setuptools/command/install.py @@ -70,8 +70,7 @@ def finalize_options(self): elif self.single_version_externally_managed: if not self.root and not self.record: raise DistutilsArgError( - "You must specify --record or --root when building system" - " packages" + "You must specify --record or --root when building system packages" ) def handle_extra_path(self): diff --git a/setuptools/tests/config/test_setupcfg.py b/setuptools/tests/config/test_setupcfg.py index 8d95798123..9f225416c0 100644 --- a/setuptools/tests/config/test_setupcfg.py +++ b/setuptools/tests/config/test_setupcfg.py @@ -415,9 +415,7 @@ def test_not_utf8(self, tmpdir): """ fake_env( tmpdir, - '# vim: set fileencoding=iso-8859-15 :\n' - '[metadata]\n' - 'description = éàïôñ\n', + '# vim: set fileencoding=iso-8859-15 :\n[metadata]\ndescription = éàïôñ\n', encoding='iso-8859-15', ) with pytest.raises(UnicodeDecodeError): diff --git a/setuptools/tests/test_build_py.py b/setuptools/tests/test_build_py.py index b8cd77dc0b..e64cfa2e4b 100644 --- a/setuptools/tests/test_build_py.py +++ b/setuptools/tests/test_build_py.py @@ -55,9 +55,9 @@ def test_recursive_in_package_data_glob(tmpdir_cwd): dist.parse_command_line() dist.run_commands() - assert stat.S_ISREG( - os.stat('build/lib/path/subpath/subsubpath/data').st_mode - ), "File is not included" + assert stat.S_ISREG(os.stat('build/lib/path/subpath/subsubpath/data').st_mode), ( + "File is not included" + ) def test_read_only(tmpdir_cwd): @@ -116,9 +116,9 @@ def test_executable_data(tmpdir_cwd): dist.parse_command_line() dist.run_commands() - assert ( - os.stat('build/lib/pkg/run-me').st_mode & stat.S_IEXEC - ), "Script is not executable" + assert os.stat('build/lib/pkg/run-me').st_mode & stat.S_IEXEC, ( + "Script is not executable" + ) EXAMPLE_WITH_MANIFEST = { diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index de257db80c..933cebb78e 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -327,9 +327,9 @@ def test_many_pth_distributions_merge_together(self, tmpdir): pth_path = str(pth_subdir.join("file1.pth")) pth1 = PthDistributions(pth_path) pth2 = PthDistributions(pth_path) - assert ( - pth1.paths == pth2.paths == [] - ), "unless there would be some default added at some point" + assert pth1.paths == pth2.paths == [], ( + "unless there would be some default added at some point" + ) # and so putting the src_subdir in folder distinct than the pth one, # so to keep it absolute by PthDistributions new_src_path = tmpdir.join("src_subdir") @@ -337,17 +337,17 @@ def test_many_pth_distributions_merge_together(self, tmpdir): new_src_path_str = str(new_src_path) pth1.paths.append(new_src_path_str) pth1.save() - assert ( - pth1.paths - ), "the new_src_path added must still be present/valid in pth1 after save" + assert pth1.paths, ( + "the new_src_path added must still be present/valid in pth1 after save" + ) # now, - assert ( - new_src_path_str not in pth2.paths - ), "right before we save the entry should still not be present" + assert new_src_path_str not in pth2.paths, ( + "right before we save the entry should still not be present" + ) pth2.save() - assert ( - new_src_path_str in pth2.paths - ), "the new_src_path entry should have been added by pth2 with its save() call" + assert new_src_path_str in pth2.paths, ( + "the new_src_path entry should have been added by pth2 with its save() call" + ) assert pth2.paths[-1] == new_src_path, ( "and it should match exactly on the last entry actually " "given we append to it in save()" @@ -719,8 +719,7 @@ def test_setup_requires_override_nspkg(self, use_setup_cfg): run_setup(test_setup_py, ['--name']) except pkg_resources.VersionConflict: self.fail( - 'Installing setup.py requirements ' - 'caused a VersionConflict' + 'Installing setup.py requirements caused a VersionConflict' ) assert 'FAIL' not in stdout.getvalue()