Skip to content

Conversation

@henryiii
Copy link
Contributor

This adds pattern matching support to Version/Specifier/SpecifierSet. You've always been able to get the components, but now you can get the string that creates one, too. For example:

item = Version("1.2")

match item:
    case Version(version):
        assert version == "1.2"

@henryiii henryiii force-pushed the henryiii/feat/patternmatch branch 3 times, most recently from ea9aa47 to b7c1f65 Compare November 28, 2025 03:07
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
@henryiii henryiii force-pushed the henryiii/feat/patternmatch branch from b7c1f65 to 3716622 Compare November 30, 2025 05:38
Copy link
Member

@notatallshaw notatallshaw left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@henryiii henryiii merged commit 7cafa45 into pypa:main Nov 30, 2025
40 checks passed
@henryiii henryiii deleted the henryiii/feat/patternmatch branch November 30, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants