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

Fix version pattern pre-releases #705

Merged
merged 2 commits into from
Aug 11, 2023
Merged

Fix version pattern pre-releases #705

merged 2 commits into from
Aug 11, 2023

Commits on Aug 5, 2023

  1. Fix version pattern pre-releases

    This commit fixes a precedence issue with version pre-release tags.
    
    Relational
    ---
    
    The `version` module exports `VERSION_PATTERN`.
    
    Directly using it, might not produce expected results for pre-releases.
    
    ```py
    >>> import re
    >>> from packaging.version import VERSION_PATTERN
    
    >>> re.match(VERSION_PATTERN, "1.0.0-alpha1")
    <re.Match object; span=(0, 7), match='1.0.0-a'>
    ```
    
    Trailing `1` from `-alpha1` is not matched, because previous pattern preferred consuming only `a` instead of `alpha` due to missing word boundary checks.
    
    Simplest solution is to re-order tokens, so regexp prefers longer tokens over
    their abbreviation.
    
    ```py
    >>> import re
    >>> from packaging.version import VERSION_PATTERN
    
    >>> re.match(VERSION_PATTERN, "1.0.0-alpha1")
    <re.Match object; span=(0, 12), match='1.0.0-alpha1'>
    ```
    
    Note: This commit also removes an unnecessary capture group.
    deathaxe committed Aug 5, 2023
    Configuration menu
    Copy the full SHA
    808bf3a View commit details
    Browse the repository at this point in the history

Commits on Aug 11, 2023

  1. Configuration menu
    Copy the full SHA
    aa8b04d View commit details
    Browse the repository at this point in the history