Skip to content

Commit

Permalink
an empty multimarker is AnyMarker, not EmptyMarker
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Nov 29, 2022
1 parent d98aa6e commit 6530ced
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/poetry/core/version/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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:
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 @@ -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",
Expand Down

0 comments on commit 6530ced

Please sign in to comment.