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

Resolve invalid python version constraint #154

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions poetry/core/packages/dependency.py
Expand Up @@ -276,6 +276,7 @@ def to_pep_508(self, with_extras: bool = True) -> str:
def _create_nested_marker(
self, name: str, constraint: Union["BaseConstraint", "VersionTypes"]
) -> str:
from poetry.core.semver.empty_constraint import EmptyConstraint
from poetry.core.semver.version import Version
from poetry.core.semver.version_union import VersionUnion

Expand Down Expand Up @@ -318,6 +319,8 @@ def _create_nested_marker(
name = "python_full_version"

marker = '{} == "{}"'.format(name, constraint.text)
elif isinstance(constraint, EmptyConstraint):
marker = ""
else:
if constraint.min is not None:
min_name = name
Expand Down
9 changes: 9 additions & 0 deletions tests/packages/test_main.py
Expand Up @@ -272,3 +272,12 @@ def test_dependency_from_pep_508_should_not_produce_empty_constraints_for_correc
str(dep.marker)
== 'platform_python_implementation != "PyPy" and python_version <= "3.10" and python_version > "3"'
)


def test_dependency_from_pep_508_with_invalid_python_version_constraint():
name = 'some-dependency ; python_version >= "3.6" and python_version <= "3.4"'
dep = Dependency.create_from_pep_508(name)

assert dep.name == "some-dependency"
assert str(dep.constraint) == "*"
assert dep.python_versions == "*"