question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`SimpleSpec` with Caret and Prerelease Wrong Behavior

See original GitHub issue

Hi, I found two issues when using SimpleSpec with caret and prerelease.

here’s the example

from semantic_version import Version, SimpleSpec

spec = SimpleSpec('^0.0.2-alpha')
print(spec.clause)

# 1st issue
# got AllOf(Range('<', Version('0.0.2')), Range('>=', Version('0.0.2-alpha')))
# which should be >=0.0.2-alpha, <0.0.3 according to https://docs.npmjs.com/cli/v6/using-npm/semver#caret-ranges-123-025-004

print(spec.match(Version('0.0.2-beta')))

# 2nd issue
# got False
# should be True

print(Version('0.0.2-beta') > Version('0.0.2-alpha'))

# got True
# this is correct

Please take a look. Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pombredannecommented, May 21, 2022

@hfudev SimpleSpec is not for Python IMHO.

FWIW, I have seen tilde and caret version ranges syntax in node-semver, rubygems-semver, Python pep440 (no caret) and composer-semver and all of the them are different even if if in a subtle way. And Python versions are not semver and the Python version ranges are not the same node-semver at all (even though it may look a bit like node-semver ranges).

In univers (a library that reuses this library) you can see how we implement support

One a side note I would strongly discourage using tilde in Python ranges (and tilde and carets elsewhere) and in general upper bounds on version ranges anywhere because of https://iscinumpy.dev/post/bound-version-constraints/

0reactions
hfudevcommented, May 21, 2022

Thanks for your patience and the blog you shared. Somehow changed my mind after reading this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python-semanticversion Documentation
Bugfix : • Fix inconsistent behaviour regarding versions with a prerelease specification. Deprecated: • Deprecate the Spec class (Removed in 3.1); ...
Read more >
npm - Does caret (^) in semver matches pre-release when pre ...
Typically a range with a caret ( ^ ) prefix such as ^1.0.0 does not result in the prerelease version 1.1.0-prerelease being installed....
Read more >
ChangeLog - rbarrois/python-semanticversion - GitHub
Fix inconsistent behaviour regarding versions with a prerelease specification. Deprecated: Deprecate the Spec class (Removed in 3.1); use the SimpleSpec ...
Read more >
semantic-version Changelog - PyUp.io
Fix bugs and unexpected behaviours in the ``SimpleSpec`` implementation. ... Fix inconsistent behaviour regarding versions with a prerelease specification.
Read more >
Make email display name configurable (!80) · Merge requests - GitLab
An error occurred while fetching the assigned milestone of the selected merge_request. Make email display name configurable.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found