Implement __le__ and __ge__ for GentooVersion - #211
Open
ArneshBanerjee wants to merge 1 commit into
Open
Conversation
GentooVersion only defined __eq__, __lt__ and __gt__, so <= and >= fell back
to the attrs generated ones that compare raw version strings. This was wrong
whenever string order differs from version order, for example
GentooVersion("1.2.0-r0") <= GentooVersion("1.10.0-r0") returned False.
AlpineLinuxVersion inherits from GentooVersion and had the same problem.
fixes: aboutcode-org#172
Signed-off-by: Arnesh <linkrinku13@gmail.com>
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.
Fixes #172
GentooVersion defines
__eq__,__lt__and__gt__, but not__le__and__ge__. Those two fall back to the ones generated by@attr.s(order=True)on the Version base class, which compare the raw version strings. That gives the wrong answer when string order and version order do not agree.AlpineLinuxVersion extends GentooVersion, so it had the same problem.
This adds
__le__and__ge__that usegentoo.vercmp, the same way ArchLinuxVersion already does, plus tests for both classes.