Skip to content
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
7 changes: 1 addition & 6 deletions src/poetry/core/version/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,16 +984,11 @@ def exclude(self, marker_name: str) -> BaseMarker:

for m in self._markers:
if isinstance(m, SingleMarkerLike) and m.name == marker_name:
# The marker is not relevant since it must be excluded
continue
return AnyMarker()

marker = m.exclude(marker_name)
new_markers.append(marker)

if not new_markers:
# All markers were the excluded marker.
return AnyMarker()

return union(*new_markers)

def only(self, *marker_names: str) -> BaseMarker:
Expand Down
12 changes: 11 additions & 1 deletion tests/version/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,10 +1583,20 @@ def test_parse_version_like_markers(marker: str, env: dict[str, str]) -> None:
'python_version >= "3.6" or extra == "foo" and implementation_name =='
' "pypy" or extra == "bar"'
),
'python_version >= "3.6" or implementation_name == "pypy"',
"",
),
('extra == "foo"', ""),
('extra == "foo" or extra == "bar"', ""),
# union with extras must collapse to "any" because the extras side of the union
# is satisfiable.
# Regression test for python-poetry/poetry#10910.
(
(
'platform_machine == "aarch64" or platform_machine == "x86_64"'
' or extra == "asyncio"'
),
"",
),
],
)
def test_without_extras(marker: str, expected: str) -> None:
Expand Down
Loading