Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't merge python_version and python_full_version #382

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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