Repository navigation
Conversation
PEP 440 treats release segments with trailing zeros as equal, but the pip provider considered 1 and 1.0 different and reinstalled a package that already met its requested version. Comparison also modified parsed version keys when their arrays had different lengths. Normalize a copied release key and pad copies during comparison. Cover equality, range membership, key stability, and provider convergence.
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.
Problem
The pip provider treats installed version
1as out of sync withensure => '1.0'. Its version comparator reports1 < 1.0, although PEP 440 pads shorter release segments with zeroes. Comparing parsed versions of different lengths also appends a sentinel to a version's stored key, so later equality checks can change depending on whether the version was compared earlier.Change
Normalize trailing zeroes in a copy of the release comparison key, and pad array copies while comparing. The original release spelling remains available for
to_s. The pip provider now accepts an already satisfied package without reinstalling it.Verification
insync?.bundle exec rspec spec/unit/util/package/version/pip_spec.rb spec/unit/util/package/version/range_spec.rb spec/unit/provider/package/pip_spec.rbpassed 3,209 examples with no failures on Ruby 3.3.[-1, false, false]to[0, true, true]for comparison, equality, and equality-range membership; comparing parsed versions no longer changes the stored key.ruby -cpassed for all three changed Ruby files;git diff --checkpassed.RuboCop could not inspect files in this container: the currently resolved RuboCop 1.92.0 and rubocop-rspec 2.31.0 combination aborts while loading
rubocop-rspec_rails, before checking source files.PEP 440 reference: https://peps.python.org/pep-0440/