Skip to content

Commit

Permalink
return least complex marker in exclude (for consistency)
Browse files Browse the repository at this point in the history
Otherwise, the expectations in the export tests had to be changed due to the previous commit.
  • Loading branch information
radoering committed Jan 19, 2025
1 parent cd5c538 commit cfb877c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/poetry/core/version/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def exclude(self, marker_name: str) -> BaseMarker:
if not marker.is_empty():
new_markers.append(marker)

return self.of(*new_markers)
return intersection(*new_markers)

def only(self, *marker_names: str) -> BaseMarker:
return self.of(*(m.only(*marker_names) for m in self._markers))
Expand Down Expand Up @@ -920,7 +920,7 @@ def exclude(self, marker_name: str) -> BaseMarker:
# All markers were the excluded marker.
return AnyMarker()

return self.of(*new_markers)
return union(*new_markers)

def only(self, *marker_names: str) -> BaseMarker:
return self.of(*(m.only(*marker_names) for m in self._markers))
Expand Down
12 changes: 12 additions & 0 deletions tests/version/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,18 @@ def test_without_extras(marker: str, expected: str) -> None:
"extra",
'python_version >= "3.6"',
),
(
(
'python_version >= "2.7" and (python_version < "2.8"'
' or python_version >= "3.7") and python_version < "3.8"'
' and extra == "foo"'
),
"extra",
(
'python_version >= "2.7" and python_version < "2.8"'
' or python_version >= "3.7" and python_version < "3.8"'
),
),
],
)
def test_exclude(marker: str, excluded: str, expected: str) -> None:
Expand Down

0 comments on commit cfb877c

Please sign in to comment.