Skip to content
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
4 changes: 2 additions & 2 deletions src/packaging/specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ def _compare_greater_than(self, prospective: Version, spec_str: str) -> bool:

# Ensure that we do not allow a local version of the version mentioned
# in the specifier, which is technically greater than, to match.
if prospective.local is not None and _base_version(
if prospective.local is not None and _public_version(
prospective
) == _base_version(spec):
) == _public_version(spec):
return False

# If we've gotten to here, it means that prospective version is both
Expand Down
22 changes: 21 additions & 1 deletion tests/test_specifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,17 @@ def test_comparison_non_specifier(self) -> None:
("2!1.0", ">2.0"),
# Test some normalization rules
("2.0.5", ">2.0dev"),
# Test local versions with pre/dev/post segments and >
# (verifies _public_version keeps pre/dev/post in the guard)
("1.0+local", ">1.0.dev1"),
("4.1.0a2.dev1235+local", ">4.1.0a2.dev1234"),
("1.0a2+local", ">1.0a1"),
("1.0b2+local", ">1.0b1"),
("1.0rc2+local", ">1.0rc1"),
("1.0.post2+local", ">1.0.post1"),
("1.0.dev2+local", ">1.0.dev1"),
("1.0a1.dev2+local", ">1.0a1.dev1"),
("1.0.post1.dev2+local", ">1.0.post1.dev1"),
]
]
+ [
Expand Down Expand Up @@ -465,7 +476,16 @@ def test_comparison_non_specifier(self) -> None:
("2.0.post1", ">2"),
("2.0.post1.dev1", ">2"),
("2.0+local.version", ">2"),
("1.0+local", ">1.0.dev1"),
("4.1.0a2.dev1234+local", ">4.1.0a2.dev1234"),
# Test local versions with pre/dev/post segments and >
# (local variant of the exact spec version must not match)
("1.0a1+local", ">1.0a1"),
("1.0b1+local", ">1.0b1"),
("1.0rc1+local", ">1.0rc1"),
("1.0.post1+local", ">1.0.post1"),
("1.0.dev1+local", ">1.0.dev1"),
("1.0a1.dev1+local", ">1.0a1.dev1"),
("1.0.post1.dev1+local", ">1.0.post1.dev1"),
# Test the less than operation
("2.0.dev1", "<2"),
("2.0a1", "<2"),
Expand Down
Loading