Fix > comparison for versions with dev+local segments#1097
Open
Fix > comparison for versions with dev+local segments#1097
Conversation
The greater-than specifier incorrectly rejected versions like 4.1.0a2.dev1235+local against >4.1.0a2.dev1234. The local version guard used _base_version which strips pre/dev/post segments, making different dev versions appear equal. Replaced with _public_version which only strips the local segment, correctly identifying when a local version genuinely differs from the spec version. Fixes pypa#810
Author
|
Manual test results: All 1216 specifier tests pass. |
Member
|
I would expect additional behavior change from changing |
Cover the behavior change from _base_version to _public_version by testing that local versions with varying pre, dev, and post segments are correctly accepted or rejected by the > operator. True cases: local versions whose public part genuinely exceeds the spec (e.g. 1.0a2+local > 1.0a1, 1.0.dev2+local > 1.0.dev1). False cases: local versions whose public part matches the spec exactly (e.g. 1.0a1+local should not match >1.0a1).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
>specifier was incorrectly rejecting versions like4.1.0a2.dev1235+localagainst>4.1.0a2.dev1234.The root cause is the local version guard in
_compare_greater_than— it used_base_version()to check if a local version matches the spec version, but_base_versionstrips pre/dev/post segments too aggressively. This made4.1.0a2.dev1235and4.1.0a2.dev1234appear as the same base version (4.1.0), so any local variant got rejected.Switched to
_public_version()which only strips the local segment. Now the comparison correctly identifies that4.1.0a2.dev1235!=4.1.0a2.dev1234, so4.1.0a2.dev1235+localproperly passes the>4.1.0a2.dev1234check.Fixes #810