Skip to content

Commit

Permalink
Merge pull request #186 from python-poetry/fix-requirements-wildcard-…
Browse files Browse the repository at this point in the history
…constraints

Fix the parsing of wildcards dependency constraints
  • Loading branch information
sdispater authored Aug 17, 2021
2 parents afaa690 + 419a854 commit 4e1f2ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions poetry/core/semver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def parse_single_constraint(constraint: str) -> VersionTypes:
op = m.group(1)
version = m.group(2)

# Technically invalid constraints like `>= 3.*` will appear
# here as `3.`.
# Pip currently supports these and to avoid breaking existing
# users workflows we need to support them as well. To do so,
# we just remove the inconsequential part.
version = version.rstrip(".")

if version == "dev":
version = "0.0-dev"

Expand Down
3 changes: 3 additions & 0 deletions tests/version/test_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def assert_requirement(req, name, url=None, extras=None, constraint="*", marker=
("name", {"name": "name"}),
("foo-bar.quux_baz", {"name": "foo-bar.quux_baz"}),
("name>=3", {"name": "name", "constraint": ">=3"}),
("name>=3.*", {"name": "name", "constraint": ">=3.0"}),
("name<3.*", {"name": "name", "constraint": "<3.0"}),
("name>3.5.*", {"name": "name", "constraint": ">3.5"}),
("name==1.0.post1", {"name": "name", "constraint": "==1.0.post1"}),
(
"name>=1.2.3;python_version=='2.6'",
Expand Down

0 comments on commit 4e1f2ab

Please sign in to comment.