From cc4f9a62889e99d0e2f7417d59ff825c14e22770 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Wed, 13 Jul 2022 00:56:57 +0100 Subject: [PATCH 1/2] fix without_extras() for marker unions --- src/poetry/core/version/markers.py | 6 ++++-- tests/version/test_markers.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/poetry/core/version/markers.py b/src/poetry/core/version/markers.py index 9eebe0017..1b5630e55 100644 --- a/src/poetry/core/version/markers.py +++ b/src/poetry/core/version/markers.py @@ -734,9 +734,11 @@ def exclude(self, marker_name: str) -> BaseMarker: continue marker = m.exclude(marker_name) + new_markers.append(marker) - if not marker.is_empty(): - new_markers.append(marker) + if not new_markers: + # All markers were the excluded marker. + return AnyMarker() return self.of(*new_markers) diff --git a/tests/version/test_markers.py b/tests/version/test_markers.py index 9bf900c47..fafff9198 100644 --- a/tests/version/test_markers.py +++ b/tests/version/test_markers.py @@ -905,6 +905,8 @@ def test_parse_version_like_markers(marker: str, env: dict[str, str]) -> None: ' "pypy" or extra == "bar"', 'python_version >= "3.6" or implementation_name == "pypy"', ), + ('extra == "foo"', ''), + ('extra == "foo" or extra == "bar"', ''), ], ) def test_without_extras(marker: str, expected: str) -> None: From 14f9e0f8020123f29e76170f3cc9c4ebc542f379 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Jul 2022 00:01:45 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/version/test_markers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/version/test_markers.py b/tests/version/test_markers.py index fafff9198..364cbed88 100644 --- a/tests/version/test_markers.py +++ b/tests/version/test_markers.py @@ -905,8 +905,8 @@ def test_parse_version_like_markers(marker: str, env: dict[str, str]) -> None: ' "pypy" or extra == "bar"', 'python_version >= "3.6" or implementation_name == "pypy"', ), - ('extra == "foo"', ''), - ('extra == "foo" or extra == "bar"', ''), + ('extra == "foo"', ""), + ('extra == "foo" or extra == "bar"', ""), ], ) def test_without_extras(marker: str, expected: str) -> None: