Skip to content
This repository was archived by the owner on Jun 2, 2022. It is now read-only.
Open
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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: stable
rev: 19.10b0
hooks:
- id: black

Expand Down
4 changes: 2 additions & 2 deletions semver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ def parse_single_constraint(constraint): # type: (str) -> VersionConstraint

version = Version.parse(m.group(1))

low = version

if precision == 2:
low = version
high = version.stable.next_major
else:
low = Version(version.major, version.minor, version.patch)
high = version.stable.next_minor

return VersionRange(
Expand Down
15 changes: 15 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@
("x.X.x.*", VersionRange()),
# ('!=1.0.0', Constraint('!=', '1.0.0.0')),
(">1.0.0", VersionRange(min=Version(1, 0, 0))),
(">1.0.0rc1", VersionRange(min=Version(1, 0, 0, pre="rc1"))),
("<1.2.3", VersionRange(max=Version(1, 2, 3))),
("<1.2.3rc1", VersionRange(max=Version(1, 2, 3, pre="rc1"))),
("<=1.2.3", VersionRange(max=Version(1, 2, 3), include_max=True)),
("<=1.2.3rc1", VersionRange(max=Version(1, 2, 3, pre="rc1"), include_max=True)),
("<=1.2rc1", VersionRange(max=Version(1, 2, 0, pre="rc1"), include_max=True)),
(">=1.2.3", VersionRange(min=Version(1, 2, 3), include_min=True)),
(">=1.2.3rc1", VersionRange(min=Version(1, 2, 3, pre="rc1"), include_min=True)),
("=1.2.3", Version(1, 2, 3)),
("=1.2.3rc1", Version(1, 2, 3, pre="rc1")),
("1.2.3", Version(1, 2, 3)),
("1.2.3rc1", Version(1, 2, 3, pre="rc1")),
("=1.0", Version(1, 0, 0)),
("1.2.3b5", Version(1, 2, 3, pre="b5")),
(">= 1.2.3", VersionRange(min=Version(1, 2, 3), include_min=True)),
Expand Down Expand Up @@ -68,6 +75,14 @@ def test_parse_constraint_wildcard(input, constraint):
("~3.5", VersionRange(Version(3, 5, 0), Version(3, 6, 0), True)),
("~=3.5", VersionRange(Version(3, 5, 0), Version(4, 0, 0), True)), # PEP 440
("~=3.5.3", VersionRange(Version(3, 5, 3), Version(3, 6, 0), True)), # PEP 440
(
"~=3.5.3rc1",
VersionRange(Version(3, 5, 3, pre="rc1"), Version(3, 6, 0), True),
), # PEP 440
(
"~=3.5rc1",
VersionRange(Version(3, 5, pre="rc1"), Version(4, 0, 0), True),
), # PEP 440
],
)
def test_parse_constraint_tilde(input, constraint):
Expand Down