Skip to content

Commit

Permalink
don't merge python_version and python_full_version
Browse files Browse the repository at this point in the history
These markers are not quite equivalent
  • Loading branch information
dimbleby authored and neersighted committed May 30, 2022
1 parent 63322f6 commit a6fe563
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
10 changes: 0 additions & 10 deletions src/poetry/core/version/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ class UndefinedEnvironmentName(ValueError):
"python_implementation": "platform_python_implementation",
}

PYTHON_VERSION_MARKERS = ["python_version", "python_full_version"]

# Parser: PEP 508 Environment Markers
_parser = Parser(GRAMMAR_PEP_508_MARKERS, "lalr")

Expand Down Expand Up @@ -416,10 +414,6 @@ def of(cls, *markers: BaseMarker) -> BaseMarker:
for i, mark in enumerate(new_markers):
if isinstance(mark, SingleMarker) and (
mark.name == marker.name
or (
mark.name in PYTHON_VERSION_MARKERS
and marker.name in PYTHON_VERSION_MARKERS
)
):
# Markers with the same name have the same constraint type,
# but mypy can't see that.
Expand Down Expand Up @@ -626,10 +620,6 @@ def of(cls, *markers: BaseMarker) -> BaseMarker:
for i, mark in enumerate(new_markers):
if isinstance(mark, SingleMarker) and (
mark.name == marker.name
or (
mark.name in PYTHON_VERSION_MARKERS
and marker.name in PYTHON_VERSION_MARKERS
)
):
# Markers with the same name have the same constraint type,
# but mypy can't see that.
Expand Down
7 changes: 6 additions & 1 deletion tests/packages/utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@
(
'(python_version < "2.7" or python_full_version >= "3.0.0") and'
' python_full_version < "3.6.0"',
{"python_version": [[("<", "2.7")], [(">=", "3.0.0"), ("<", "3.6.0")]]},
{
"python_version": [
[("<", "2.7"), ("<", "3.6.0")],
[(">=", "3.0.0"), ("<", "3.6.0")],
]
},
),
(
'(python_version < "2.7" or python_full_version >= "3.0.0") and'
Expand Down
18 changes: 12 additions & 6 deletions tests/version/test_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,15 @@ def test_single_marker_not_in_python_intersection() -> None:


def test_marker_intersection_of_python_version_and_python_full_version() -> None:
m = parse_marker('python_version >= "3.6"')
m2 = parse_marker('python_full_version >= "3.0.0"')
m = parse_marker('python_version > "3.6"')
m2 = parse_marker('python_full_version >= "3.6.2"')
intersection = m.intersect(m2)

assert str(intersection) == 'python_version >= "3.6"'
# 'python_version > "3.6"' would be good, but not
# 'python_full_version >= "3.6.2"'.
assert (
str(intersection) == 'python_version > "3.6" and python_full_version >= "3.6.2"'
)


def test_single_marker_union() -> None:
Expand Down Expand Up @@ -521,11 +525,13 @@ def test_marker_union_deduplicate() -> None:


def test_marker_union_of_python_version_and_python_full_version() -> None:
m = parse_marker('python_version >= "3.6"')
m2 = parse_marker('python_full_version >= "3.0.0"')
m = parse_marker('python_version > "3.6"')
m2 = parse_marker('python_full_version >= "3.6.2"')
union = m.union(m2)

assert str(union) == 'python_full_version >= "3.0.0"'
# 'python_full_version >= "3.6.2"' would be good, but not
# 'python_version > "3.6"'.
assert str(union) == 'python_version > "3.6" or python_full_version >= "3.6.2"'


def test_marker_union_intersect_single_marker() -> None:
Expand Down

0 comments on commit a6fe563

Please sign in to comment.