-
Notifications
You must be signed in to change notification settings - Fork 995
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
Update python version regex and fix version ordering #10613
base: main
Are you sure you want to change the base?
Conversation
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.
Is there a merged python regex update changes related to this test cases? Or this is refining the test cases? I couldn't see the regex changes here?
5b5c2f8
to
1ee202d
Compare
@@ -104,7 +105,7 @@ | |||
"1.0.0-beta.11", | |||
"1.0.0-rc.1", | |||
"1", | |||
# "1.0.0.post", TODO fails comparing to 1 | |||
"1.0.0.post", # TODO: fails comparing to 1 |
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 saw this red flag while adding the test cases and was curious to find out what the sorted list looks like.
expected: ["", "0.9", "1.0.0-alpha", "1.0.0-a.1", "1.0.0-beta", "1.0.0-b.2", "1.0.0-beta.11", "1.0.0-rc.1", "1", "1.0.0.post", "1.0.0+gc1", "1.post2", "1.post2+gc1", "1.post2+gc1.2", "1.post2+gc1.11", "1.0.0.post11", "1.0.2", "1.0.11", "2016.1", "1!0.1.0", "2!0.1.0", "10!0.1.0"]
got: ["", "0.9", "1", "1!0.1.0", "1.0.0+gc1", "1.0.0-a.1", "1.0.0-alpha", "1.0.0-b.2", "1.0.0-beta", "1.0.0-beta.11", "1.0.0-rc.1", "1.0.0.post", "1.0.0.post11", "1.0.11", "1.0.2", "1.post2", "1.post2+gc1", "1.post2+gc1.11", "1.post2+gc1.2", "10!0.1.0", "2!0.1.0", "2016.1"]
There are a few things wrong with this output. The first is that it's not sorting version epocs correctly. In ascending order, versions like "1!1.0" should come after versions without an epoch like "0.9" which is equivalent to 0!0.9.
The epocs also need to be ordered numerically as in "1!0.1.0", "2!0.1.0", "10!0.1.0" and this is not the case here where we are ordering alphabetically.
We are also ordering versions without epochs alphabetically rather than numerically and that is why we have "1.0.11" appear before "1.0.2". The python version spec is clear on this
All numeric components MUST be interpreted and ordered according to their numeric value, not as text strings.
Finally, the sort order for versions with suffixes is also incorrect. The python spec say the correct order is .devN, aN, bN, rcN, , .postN and within each suffix we should sort numerically where applicable.
So "1.0.0-alpha" < "1.0.0-a.1" but we're seeing the opposite. Likewise, in the commented out test "1" < "1.0.0.post" but that's not what we get.
It's coming. It's got python regex features and converting those to ruby has been problematic so far.
|
1ee202d
to
49a1514
Compare
What are you trying to accomplish?
Link to issue
Update our python version implementation to be conformant with the python version specification here: https://peps.python.org/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions
I'm updating the regex for version formats to be the one specified in the python version specification.
Anything you want to highlight for special attention from reviewers?
How will you know you've accomplished your goal?
Checklist