From 61b4cca5e729ed2eb883b5af96a29ab24687a011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randy=20D=C3=B6ring?= <30527984+radoering@users.noreply.github.com> Date: Sat, 12 Mar 2022 19:02:03 +0100 Subject: [PATCH] Fix special case of get_python_constraint_from_marker() and SingleMarker.only() --- src/poetry/core/version/markers.py | 4 ++-- tests/packages/utils/test_utils.py | 1 + tests/version/test_markers.py | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/poetry/core/version/markers.py b/src/poetry/core/version/markers.py index 914159667..5c2b01fbb 100644 --- a/src/poetry/core/version/markers.py +++ b/src/poetry/core/version/markers.py @@ -294,9 +294,9 @@ def exclude(self, marker_name: str) -> BaseMarker: return self - def only(self, *marker_names: str) -> Union["SingleMarker", EmptyMarker]: + def only(self, *marker_names: str) -> Union["SingleMarker", AnyMarker]: if self.name not in marker_names: - return EmptyMarker() + return AnyMarker() return self diff --git a/tests/packages/utils/test_utils.py b/tests/packages/utils/test_utils.py index eaef43ae2..a6aefc889 100644 --- a/tests/packages/utils/test_utils.py +++ b/tests/packages/utils/test_utils.py @@ -35,6 +35,7 @@ def test_convert_markers(): 'python_full_version >= "3.6.1" and python_full_version < "4.0.0"', ">=3.6.1, <4.0.0", ), + ('sys_platform == "linux"', "*"), ], ) def test_get_python_constraint_from_marker(marker: str, constraint: str): diff --git a/tests/version/test_markers.py b/tests/version/test_markers.py index be1ef3c2b..afd477509 100644 --- a/tests/version/test_markers.py +++ b/tests/version/test_markers.py @@ -738,6 +738,7 @@ def test_exclude(marker: str, excluded: str, expected: str): "marker, only, expected", [ ('python_version >= "3.6"', ["python_version"], 'python_version >= "3.6"'), + ('python_version >= "3.6"', ["sys_platform"], ""), ( 'python_version >= "3.6" and extra == "foo"', ["python_version"],