Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix special case of get_python_constraint_from_marker() and SingleMarker.only() #307

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/poetry/core/version/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
abn marked this conversation as resolved.
Show resolved Hide resolved
if self.name not in marker_names:
return EmptyMarker()
return AnyMarker()

return self

Expand Down
1 change: 1 addition & 0 deletions tests/packages/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions tests/version/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down