Title: Implement Extended Version Comparisons (Ranges, Hyphens, Tilde...) · Issue #241 · python-semver/python-semver · GitHub
Open Graph Title: Implement Extended Version Comparisons (Ranges, Hyphens, Tilde...) · Issue #241 · python-semver/python-semver
X Title: Implement Extended Version Comparisons (Ranges, Hyphens, Tilde...) · Issue #241 · python-semver/python-semver
Description: 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 provide...
Open Graph Description: 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. Propos...
X Description: 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. Propos...
Opengraph URL: https://github.com/python-semver/python-semver/issues/241
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Implement Extended Version Comparisons (Ranges, Hyphens, Tilde...)","articleBody":"# Situation\r\n\r\nCurrently, ~`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.\r\n\r\n# Proposal\r\n\r\nAdd an additional class which provides all the necessary functionality. How this is implemented is a matter of design. :wink: \r\n\r\nI'd suggest to add this after major 3 is released.\r\n\r\nThis could be the use cases (I use a class `Spec` here, but the naming is subject to change):\r\n\r\n```python\r\n\u003e\u003e\u003e import semver\r\n\u003e\u003e\u003e spec = semver.Spec(\"\u003e=1.0 \u003c= 1.7\")\r\n\u003e\u003e\u003e ver = semver.Version.parse(\"1.2.0\")\r\n\r\n\u003e\u003e\u003e spec in ver\r\nTrue\r\n\u003e\u003e\u003e spec.match(ver)\r\nTrue\r\n```\r\n\r\nDepending 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?\r\n\r\n@python-semver/reviewers What do you think about this idea? Any preferences?\r\n\r\n# Grammar\r\n\r\n\r\n```\r\nrange-set ::= range ( logical-or range ) *\r\nlogical-or ::= ( ' ' ) * '||' ( ' ' ) *\r\nrange ::= hyphen | simple ( ' ' simple ) * | ''\r\nhyphen ::= partial ' - ' partial\r\nsimple ::= primitive | partial | tilde | caret\r\nprimitive ::= ( '\u003c' | '\u003e' | '\u003e=' | '\u003c=' | '=' ) partial\r\npartial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?\r\nxr ::= 'x' | 'X' | '*' | nr\r\nnr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *\r\ntilde ::= '~' partial\r\ncaret ::= '^' partial\r\nqualifier ::= ( '-' pre )? ( '+' build )?\r\npre ::= parts\r\nbuild ::= parts\r\nparts ::= part ( '.' part ) *\r\npart ::= nr | [-0-9A-Za-z]+\r\n```\r\n\r\n# See Also\r\n\r\n* https://docs.npmjs.com/cli/v6/using-npm/semver\r\n* https://github.com/rbarrois/python-semanticversion/blob/master/semantic_version/base.py#L586\r\n* http://instaparse.mojombo.com/\r\n* [Parsing a \"simple\" grammar](https://stackoverflow.com/a/43364275)\r\n* [Building Recursive Descent Parsers: The Definitive Guide](https://www.booleanworld.com/building-recursive-descent-parsers-definitive-guide/)\r\n* [Parsing Expressions](https://craftinginterpreters.com/parsing-expressions.html)","author":{"url":"https://github.com/tomschr","@type":"Person","name":"tomschr"},"datePublished":"2020-04-22T11:20:09.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/241/python-semver/issues/241"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:139dbd1f-ae6f-87eb-0283-a6b594e737b2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B3C8:3F9D41:1FBDDE:2C2E3D:696F318A |
| html-safe-nonce | 95fd12d7309bcb8465bd9a4c3d6fd39f6c33927073986f69f07cc63439e115f6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCM0M4OjNGOUQ0MToxRkJEREU6MkMyRTNEOjY5NkYzMThBIiwidmlzaXRvcl9pZCI6IjI4MjAyMjU3ODM0NTgzNzgxMjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 797d89207d1fc87f9d5a2a32accde66cfc8674b8c78fa2452de59352a857f573 |
| hovercard-subject-tag | issue:604675574 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-semver/python-semver/241/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e8a9b79b2f44d0281be0fc7ced2eecfe63a22c0271185af9b08933d9f4bf9ace/python-semver/python-semver/issues/241 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e8a9b79b2f44d0281be0fc7ced2eecfe63a22c0271185af9b08933d9f4bf9ace/python-semver/python-semver/issues/241 |
| og:image:alt | 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. Propos... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tomschr |
| hostname | github.com |
| expected-hostname | github.com |
| None | b278ad162d35332b6de714dfb005de04386c4d92df6475522bef910f491a35ee |
| turbo-cache-control | no-preview |
| go-import | github.com/python-semver/python-semver git https://github.com/python-semver/python-semver.git |
| octolytics-dimension-user_id | 57228994 |
| octolytics-dimension-user_login | python-semver |
| octolytics-dimension-repository_id | 3375726 |
| octolytics-dimension-repository_nwo | python-semver/python-semver |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3375726 |
| octolytics-dimension-repository_network_root_nwo | python-semver/python-semver |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 39aed5006635ab6f45e6b77d23e73b08a00272a3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width