-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make LooseVersion('1.0') == LooseVersion('1')
#4691
Conversation
903603f
to
3aea4b6
Compare
Remove the pitfall where missing components were filled with empty strings that are less than any other value. The common expectation is that trailing zeroes are equal to zeroes. If the trailing part is a string the current behavior is kept.
865094f
to
60cc742
Compare
Currently there is no way to detect whether a version was defaulted. The current default value ('0.0.0') is a valid value for the versions list and the appropriate default comparator for that should be `==`. However such a version is (mis-)detected as being the default and the resulting default comparator is `>=` which is less restrictive than intended. Fix by introducing a property set only for the default version.
The default_version `1.0` no longer matches `> 1` so raise to 1.1
60cc742
to
aa038b3
Compare
I bet that some stupid developer will make version 1 and then produce version 1.0 as being newer then 1... |
Sure. But technically The documentation:
to me implies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not aware of any situations where this actually has mattered, but i'm fine with the logic change.
I agree with the premise that You can have development and alpha versions like |
I'd just add the note that we use this not really specific for python packages but for all kinds of software packages which probably don't feel a need to follow PEP440 (but they also probably don't feel a need to follow semver or any other guides and just do whatever the heck they want) If a develop actually make a I thinking it's mostly going to be us that might use the single digit, for scenarios like if self.version >= LooseVersion('7.0'): # what if version is just 7?
self.new_installation_step()
else:
self.legacy_installation_step() edit: uhm, i didn't think that example through, i hoped i fixed it to a maybe-realistic scenario. |
As I said, I agree with this change. It is easier to dance around rare exotic versions than having to constantly handle |
I don't read it as such. The opposite: We fix this to match the described PEP:
My understanding of
is that Our class doesn't follow that though: Because @Micket How about: With this change they'd all be equal, i.e. True, before the former was false, the latter true if I'm not mistaken. |
yes I'm in favour of this change, I tried to write an example where the old behavior was undesirable. I asked the other maintainers for opinions, and it doesn't seem like people have strong opinions or vaguely in favor, so in this goes. |
Remove the pitfall where missing components were filled with empty strings that are less than any other value.
The common expectation is that trailing zeroes are equal to zeroes.
I don't think there is any case where
1.0 > 1
is intendedIf the trailing part is a string the current behavior is kept.
See the changed test case where "# Careful here: 1.0 > 1 !!!" can be removed now.