Skip to content
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

Merged
merged 14 commits into from
Oct 10, 2024

Conversation

amazimbe
Copy link
Contributor

@amazimbe amazimbe commented Sep 16, 2024

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

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

Copy link
Contributor

@kbukum1 kbukum1 left a 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?

@amazimbe amazimbe force-pushed the amazimbe/update-python-version-regex branch from 5b5c2f8 to 1ee202d Compare September 17, 2024 09:46
@amazimbe
Copy link
Contributor Author

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?

It's coming. It's got python regex features and converting those to ruby has been problematic so far.

VERSION_PATTERN = r"""
    v?
    (?:
        (?:(?P<epoch>[0-9]+)!)?                           # epoch
        (?P<release>[0-9]+(?:\.[0-9]+)*)                  # release segment
        (?P<pre>                                          # pre-release
            [-_\.]?
            (?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
            [-_\.]?
            (?P<pre_n>[0-9]+)?
        )?
        (?P<post>                                         # post release
            (?:-(?P<post_n1>[0-9]+))
            |
            (?:
                [-_\.]?
                (?P<post_l>post|rev|r)
                [-_\.]?
                (?P<post_n2>[0-9]+)?
            )
        )?
        (?P<dev>                                          # dev release
            [-_\.]?
            (?P<dev_l>dev)
            [-_\.]?
            (?P<dev_n>[0-9]+)?
        )?
    )
    (?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))?       # local version
"""

@amazimbe amazimbe changed the title Update python version regex and add test cases Update python version regex and fix version ordering Sep 18, 2024
@amazimbe amazimbe force-pushed the amazimbe/update-python-version-regex branch from 1ee202d to 49a1514 Compare September 19, 2024 14:08
@amazimbe amazimbe force-pushed the amazimbe/update-python-version-regex branch from 49a1514 to caae23c Compare October 2, 2024 11:56
@amazimbe amazimbe force-pushed the amazimbe/update-python-version-regex branch 2 times, most recently from 89cc502 to 5308ab8 Compare October 8, 2024 14:31
@amazimbe amazimbe marked this pull request as ready for review October 8, 2024 14:31
@amazimbe amazimbe requested a review from a team as a code owner October 8, 2024 14:31
Copy link
Contributor

@pavera pavera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good in general. My only concern is I'm not sure how widespread adherence to this standard is across the python community. Projects which deviate, but were "allowed" under the old regex will now fail to get updates.

@amazimbe
Copy link
Contributor Author

amazimbe commented Oct 9, 2024

I think this looks good in general. My only concern is I'm not sure how widespread adherence to this standard is across the python community. Projects which deviate, but were "allowed" under the old regex will now fail to get updates.

Thanks @pavera . I'll add your concern to the discussion but so far I haven't encountered a version that was valid under the previous regex that is no longer valid under the new regex.

@amazimbe amazimbe force-pushed the amazimbe/update-python-version-regex branch from 5308ab8 to 7b5de61 Compare October 9, 2024 22:41
@amazimbe
Copy link
Contributor Author

amazimbe commented Oct 9, 2024

@pavera I've had to add a feature flag, in case, things go wrong after deploying. It's mostly code that I'll clean up soon after deploying but do let me know if you have any additional feedback.

@amazimbe amazimbe force-pushed the amazimbe/update-python-version-regex branch from 06199e5 to 9085677 Compare October 10, 2024 16:39
@amazimbe amazimbe merged commit e6a56e9 into main Oct 10, 2024
59 checks passed
@amazimbe amazimbe deleted the amazimbe/update-python-version-regex branch October 10, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants