You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement Extended Version Comparisons (Ranges, Hyphens, Tilde...) #241
Currently, semver.VersionInfosemver.Version contains a match method. However, it does support only a limited number of comparisons. For example, ~ or ^ as known in NPM is unknown.
Proposal
Add an additional class which provides all the necessary functionality. How this is implemented is a matter of design. 😉
I'd suggest to add this after major 3 is released.
This could be the use cases (I use a class Spec here, but the naming is subject to change):
Depending on how we want to design it, it could also influence, for example, semver.Version.match. Maybe we should (re)move that and move this functionality into a future Spec class? Wouldn't it a bit more appropriate there?
@python-semver/reviewers What do you think about this idea? Any preferences?
Grammar
range-set ::= range ( logical-or range ) *
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
range ::= hyphen | simple ( ' ' simple ) * | ''
hyphen ::= partial ' - ' partial
simple ::= primitive | partial | tilde | caret
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
xr ::= 'x' | 'X' | '*' | nr
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
tilde ::= '~' partial
caret ::= '^' partial
qualifier ::= ( '-' pre )? ( '+' build )?
pre ::= parts
build ::= parts
parts ::= part ( '.' part ) *
part ::= nr | [-0-9A-Za-z]+
Activity
Fix python-semver#241: Implement tilde and caret matching
Fix python-semver#241: Implement tilde and caret matching
levimatheri commentedon Feb 25, 2025
Any update on the progress of this?
tomschr commentedon Feb 25, 2025
@levimatheri
Thanks for asking! I've tried different approaches, you can find one in #367. None of them were very convincing, so I'm not sure yet how to proceed.
If you have a good implementation idea, I'd like to hear it. Share it here. 🙂