diff --git a/src/poetry/core/version/markers.py b/src/poetry/core/version/markers.py index 6a585ad9b..00b203bc0 100644 --- a/src/poetry/core/version/markers.py +++ b/src/poetry/core/version/markers.py @@ -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 diff --git a/tests/version/test_markers.py b/tests/version/test_markers.py index 2223e3068..e63c2e940 100644 --- a/tests/version/test_markers.py +++ b/tests/version/test_markers.py @@ -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(