Skip to content

Conversation

@arjunaskykok
Copy link

This PR fixes this bug: #100.

@rbarrois
Copy link
Owner

Thanks for the contribution! Could you explain why this fixes the bug? Ideally in comments or the commit message, but I can add it myself — as long as I understand it :D

@arjunaskykok
Copy link
Author

@rbarrois So without the fix, this is what happens.

>>> from semantic_version import NpmSpec, Version
>>> NpmSpec("<1.2.3-beta.7").clause
AnyOf(AllOf(Range('<', Version('1.2.3'), prerelease_policy='same-patch')), AllOf(Range('<', Version('1.2.3-beta.7'), prerelease_policy='same-patch'), Range('>=', Version('1.2.0'), prerelease_policy='always')))

Notice there is this clause AllOf(Range('<', Version('1.2.3'), prerelease_policy='same-patch')), so every prerelease (alpha-1,2,3,4,..., beta-1,2,3,4,...., rc-1,2,3,4,....) version always matches because versions 1.2.3-rc.4 or 1.2.3-alpha.7 or 1.2.3-beta.8 is always less than version 1.2.3. Basically, my fix removes this clause.

To be fair, I consider my patch as a quick fix, not as a holistic one. I don't fully understand how NPM spec matching engine works. :)

I mean I can update the PR to add a comment but I just need to make sure you are okay with my patch.

jjmaestro added a commit to jjmaestro/bazel_version_utils that referenced this pull request Jul 16, 2025
Fixes [`python-semanticversion #100`].

Credit to `@arjunaskykok`, author of [`python-semanticversion #101`].

[`python-semanticversion #100`]: rbarrois/python-semanticversion#100
[`python-semanticversion #101`]: rbarrois/python-semanticversion#101
jjmaestro added a commit to jjmaestro/bazel_version_utils that referenced this pull request Jul 16, 2025
* Add additional tests mentioned in the comments of
  [`python-semanticversion #100`].

* Comment out the test cases that fail (these will be fixed in the next
  commits).

Credit to `@ugomancz` and `@tysonliddell` for the tests cases!

[`python-semanticversion #100`]: rbarrois/python-semanticversion#101
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