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

PEP 508 parsing: handle "== V.*" correctly #56

Merged
merged 1 commit into from
Aug 3, 2020
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
2 changes: 1 addition & 1 deletion poetry/core/packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def dependency_from_pep_508(
ands = []
for op, version in or_:
# Expand python version
if op == "==":
if op == "==" and "*" not in version:
version = "~" + version
op = ""
elif op == "!=":
Expand Down
18 changes: 18 additions & 0 deletions tests/packages/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,21 @@ def test_dependency_from_pep_508_with_python_full_version():
'python_version >= "2.7" and python_version < "2.8" '
'or python_full_version >= "3.4" and python_full_version < "3.5.4"'
)


def test_dependency_from_pep_508_with_python_full_version_pep440_compatible_release_astrix():
name = 'pathlib2 ; python_version == "3.4.*" or python_version < "3"'
dep = dependency_from_pep_508(name)

assert dep.name == "pathlib2"
assert str(dep.constraint) == "*"
assert dep.python_versions == "==3.4.* || <3"


def test_dependency_from_pep_508_with_python_full_version_pep440_compatible_release_tilde():
name = 'pathlib2 ; python_version ~= "3.4" or python_version < "3"'
dep = dependency_from_pep_508(name)

assert dep.name == "pathlib2"
assert str(dep.constraint) == "*"
assert dep.python_versions == "~=3.4 || <3"
4 changes: 4 additions & 0 deletions tests/semver/test_parse_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"constraint,version",
[
("~=3.8", VersionRange(min=Version(3, 8), max=Version(4, 0), include_min=True)),
(
"== 3.8.*",
VersionRange(min=Version(3, 8), max=Version(3, 9, 0), include_min=True),
),
(
"~= 3.8",
VersionRange(min=Version(3, 8), max=Version(4, 0), include_min=True),
Expand Down