From 6530ced82673430b1fa677b9fe026d7bba610db8 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Tue, 29 Nov 2022 22:46:06 +0000 Subject: [PATCH] an empty multimarker is AnyMarker, not EmptyMarker --- src/poetry/core/version/markers.py | 8 +++++++- tests/version/test_markers.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/poetry/core/version/markers.py b/src/poetry/core/version/markers.py index 8915d53c9..70bd52c56 100644 --- a/src/poetry/core/version/markers.py +++ b/src/poetry/core/version/markers.py @@ -435,9 +435,12 @@ def of(cls, *markers: BaseMarker) -> BaseMarker: new_markers.append(marker) - if any(m.is_empty() for m in new_markers) or not new_markers: + if any(m.is_empty() for m in new_markers): return EmptyMarker() + if not new_markers: + return AnyMarker() + if len(new_markers) == 1: return new_markers[0] @@ -577,6 +580,9 @@ def only(self, *marker_names: str) -> BaseMarker: if not marker.is_empty(): new_markers.append(marker) + if not new_markers: + return EmptyMarker() + return self.of(*new_markers) def invert(self) -> BaseMarker: diff --git a/tests/version/test_markers.py b/tests/version/test_markers.py index 345dca1e6..d62e6feb4 100644 --- a/tests/version/test_markers.py +++ b/tests/version/test_markers.py @@ -933,6 +933,7 @@ def test_without_extras(marker: str, expected: str) -> None: [ ('python_version >= "3.6"', "implementation_name", 'python_version >= "3.6"'), ('python_version >= "3.6"', "python_version", "*"), + ('python_version >= "3.6" and python_version < "3.11"', "python_version", "*"), ( 'python_version >= "3.6" and extra == "foo"', "extra",