Skip to content

Commit

Permalink
fix simplification of python_version markers to AnyMarker (#838)
Browse files Browse the repository at this point in the history
Fixes `Could not parse version constraint: ==*`
  • Loading branch information
radoering authored Feb 16, 2025
1 parent 895d49c commit a225083
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/poetry/core/version/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1222,11 +1222,14 @@ def _merge_single_markers(

elif isinstance(result_constraint, VersionUnion) and merge_class == MarkerUnion:
# Convert 'python_version == "3.8" or python_version >= "3.9"'
# to 'python_version >= "3.8"'
# to 'python_version >= "3.8"'.
# Convert 'python_version <= "3.8" or python_version >= "3.9"' to "any".
result_constraint = get_python_constraint_from_marker(marker1).union(
get_python_constraint_from_marker(marker2)
)
if result_constraint.is_simple():
if result_constraint.is_any():
result_marker = AnyMarker()
elif result_constraint.is_simple():
result_marker = SingleMarker(marker1.name, result_constraint)

return result_marker
Expand Down
5 changes: 5 additions & 0 deletions tests/version/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ def test_single_marker_union_is_any() -> None:
'python_version >= "3.7"',
'python_version >= "3.6"',
),
(
'python_version <= "3.6"',
'python_version >= "3.7"',
"",
),
],
)
def test_single_marker_union_is_single_marker(
Expand Down

0 comments on commit a225083

Please sign in to comment.