From 40c56e200263566a9f49ee7e7c6c17c7627592ec Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 3 Aug 2024 20:38:56 +0200 Subject: [PATCH 1/4] Let _show_help() use commands instead of self.commands Depending on the context, _show_help() is called with a different commands argument. I believe the intent was to adapt the help message to the context. However, it would operate on self.commands instead of the commands argument, which would break this purpose. --- distutils/dist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distutils/dist.py b/distutils/dist.py index 0a57d60be9..115302b3e7 100644 --- a/distutils/dist.py +++ b/distutils/dist.py @@ -658,7 +658,7 @@ def _show_help( ) print() - for command in self.commands: + for command in commands: if isinstance(command, type) and issubclass(command, Command): klass = command else: From ab13bf2c34ce2e1bce60cc8a752b9a2065a83df5 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Sat, 3 Aug 2024 21:36:13 +0200 Subject: [PATCH 2/4] Enforce flake8-bugbear (B) and isort (I) ruff rules Ignore B028 and B904. --- ruff.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ruff.toml b/ruff.toml index b7850b6ddd..41c9459bdb 100644 --- a/ruff.toml +++ b/ruff.toml @@ -5,6 +5,8 @@ extend-select = [ "W", # local + "B", + "I", "ISC", "RUF010", "RUF100", @@ -26,6 +28,10 @@ ignore = [ "COM819", "ISC001", "ISC002", + + # local + "B028", + "B904", ] [format] From 9a9946f98a5c1597a230db5975bdd61dc1ca1a3f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Aug 2024 16:10:01 -0400 Subject: [PATCH 3/4] Add test capturing missed expectation. Ref pypa/distutils#284 --- distutils/tests/test_modified.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/distutils/tests/test_modified.py b/distutils/tests/test_modified.py index 2bd82346cf..4f1a7caf9a 100644 --- a/distutils/tests/test_modified.py +++ b/distutils/tests/test_modified.py @@ -117,3 +117,11 @@ def test_newer_pairwise_group(groups_target): newer = newer_pairwise_group([groups_target.newer], [groups_target.target]) assert older == ([], []) assert newer == ([groups_target.newer], [groups_target.target]) + + +@pytest.mark.xfail(reason="pypa/distutils#284") +def test_newer_group_no_sources_no_target(tmp_path): + """ + Consider no sources and no target "newer". + """ + assert newer_group([], str(tmp_path / 'does-not-exist')) From 30b7331b07fbc404959cb37ac311afdfb90813be Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Aug 2024 16:11:46 -0400 Subject: [PATCH 4/4] Ensure a missing target is still indicated as 'sources are newer' even when there are no sources. Closes pypa/distutils#284 --- distutils/_modified.py | 2 +- distutils/tests/test_modified.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/distutils/_modified.py b/distutils/_modified.py index 6532aa1073..b7bdaa2943 100644 --- a/distutils/_modified.py +++ b/distutils/_modified.py @@ -63,7 +63,7 @@ def missing_as_newer(source): return missing == 'newer' and not os.path.exists(source) ignored = os.path.exists if missing == 'ignore' else None - return any( + return not os.path.exists(target) or any( missing_as_newer(source) or _newer(source, target) for source in filter(ignored, sources) ) diff --git a/distutils/tests/test_modified.py b/distutils/tests/test_modified.py index 4f1a7caf9a..e35cec2d6f 100644 --- a/distutils/tests/test_modified.py +++ b/distutils/tests/test_modified.py @@ -119,7 +119,6 @@ def test_newer_pairwise_group(groups_target): assert newer == ([groups_target.newer], [groups_target.target]) -@pytest.mark.xfail(reason="pypa/distutils#284") def test_newer_group_no_sources_no_target(tmp_path): """ Consider no sources and no target "newer".