Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Implement Extended Version Comparisons (Ranges, Hyphens, Tilde...) #241

Copy link
Copy link
Open
@tomschr

Description

@tomschr
Issue body actions

Situation

Currently, semver.VersionInfo semver.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):

>>> import semver
>>> spec = semver.Spec(">=1.0 <= 1.7")
>>> ver = semver.Version.parse("1.2.0")

>>> spec in ver
True
>>> spec.match(ver)
True

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]+

See Also

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNot a bug, but increases or improves in value, quality, desirability, or attractivenessNot a bug, but increases or improves in value, quality, desirability, or attractivenessQuestionUnclear or open issue subject for debateUnclear or open issue subject for debateRelease_3.x.yOnly for the major release 3Only for the major release 3

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.