-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes unstable next breaking version when major is 0 #475
Fixes unstable next breaking version when major is 0 #475
Conversation
570664f
to
d1bfe63
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a reasonable interpretation of next_breaking()
to me, as well as apparently being what poetry 1.1 used to do. On the other hand the unfixed interpretation also seems reasonable, so I'd welcome maintainer opinion...
Per python-poetry/poetry#6519 (comment), it's not clear that this is really the problem that you wanted to solve anyway.
on further investigating PEP440 I no longer think that the unfixed interpretation is reasonable
So eg That doesn't seem like a useful meaning of So this looks good to me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still some cases that might not be correct:
^0.1
becomes >=0.1,<0.2
but
^0.1-alpha.1
becomes >=0.1-alpha.1,<0.1.1
That's probably not expected, is it?
Can you add a dedicated unit test for next_breaking
in tests/semver/test_version.py
similar to the tests in tests/pep440/test_version.py
for the next_...
methods of PEP440Version
, please?
good spot. There's more than one way to skin a cat, but I'll re-suggest python-poetry/poetry#6519 (comment)
|
@radoering There's also a general issue where
|
be0f456
to
d9d6cd9
Compare
My last comment feels a bit too much opinionated so I kept the precision in |
d9d6cd9
to
b003df9
Compare
b003df9
to
95c9598
Compare
I appreciate all the tests! If anything I'd say you've gone a little over the top here, but I shouldn't discourage tests! I have some questions
I'd also suggest that a simpler fix to make if self.is_stable():
return self
- return self.next_patch()
+ stable = Version(release=self.release, epoch=self.epoch)
+ return stable |
oh also I now notice that you've changed the implementation of stable() so that it sometimes returns a postrelease. (I was blind to this before on account of it moving between classes). Again this seems like a change that is somewhere between not-needed-right-now and I-dont-even-know-whether-its-right. Edit: it probably is right, if (my suggested reimplementation of |
Here are some example of what
Very weird behaviour and it was used in The reason why So the expected behavior's for next_breaking are:
Adding |
We're talking past each other. I've no problem with |
3124ea9
to
87a7c65
Compare
(i) (ii) I just implemented it |
poetry-core's I propose that the entire diff in diff --git a/src/poetry/core/semver/version.py b/src/poetry/core/semver/version.py
index 2fe6fe8..4746121 100644
--- a/src/poetry/core/semver/version.py
+++ b/src/poetry/core/semver/version.py
@@ -32,21 +32,17 @@ class Version(PEP440Version, VersionRangeConstraint):
if self.is_stable():
return self
- return self.next_patch()
+ post = self.post if self.pre is None else None
+ return Version(release=self.release, post=post, epoch=self.epoch)
def next_breaking(self) -> Version:
- if self.major == 0:
- if self.minor is not None and self.minor != 0:
- return self.next_minor()
+ if self.major > 0 or self.minor is None:
+ return self.stable.next_major()
- if self.precision == 1:
- return self.next_major()
- elif self.precision == 2:
- return self.next_minor()
+ if self.minor > 0 or self.patch is None:
+ return self.stable.next_minor()
- return self.next_patch()
-
- return self.stable.next_major()
+ return self.stable.next_patch() your tests for |
Alright, let me move things around. Btw, SonarCloud is freaking out because I'll restate my concern about the following even if this PR won't deal with it. @dataclasses.dataclass(frozen=True)
class Version(PEP440Version, VersionRangeConstraint):
"""
A parsed semantic version number.
"""
...
# This should not work as `0.1` is not a valid semantic version
Version.parse('0.1').text == "0.1"
# Either, raises an error
Version.parse("0.1")
# Or
Version.parse("0.1").text == "0.1.0" |
87a7c65
to
f256b28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me but (i) I'm more or less reviewing my own code at this point and (ii) my review doesn't count for anything anyway
@radoering would you be so kind to rereview this PR and there seems to be an issue with SonarCloud which thinks the version |
The class has some semver related methods (like |
f256b28
to
9992889
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [poetry](https://python-poetry.org/) ([source](https://github.com/python-poetry/poetry), [changelog](https://python-poetry.org/history/)) | patch | `1.3.1` -> `1.3.2` | --- ### Release Notes <details> <summary>python-poetry/poetry</summary> ### [`v1.3.2`](https://github.com/python-poetry/poetry/blob/HEAD/CHANGELOG.md#poetry-core-132-httpsgithubcompython-poetrypoetry-corereleasestag132) [Compare Source](python-poetry/poetry@1.3.1...1.3.2) - Add `3.11` to the list of available Python versions ([#​477](python-poetry/poetry-core#477)). - Fix an issue where caret constraints of pre-releases with a major version of 0 resulted in an empty version range ([#​475](python-poetry/poetry-core#475)). </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC45NC4wIiwidXBkYXRlZEluVmVyIjoiMzQuOTQuMCJ9--> Reviewed-on: https://git.walbeck.it/walbeck-it/docker-python-poetry/pulls/573 Co-authored-by: renovate-bot <bot@walbeck.it> Co-committed-by: renovate-bot <bot@walbeck.it>
Resolves: python-poetry/poetry#6519
What this PR contains:
Version.stable
toPEP440Version.stable
asVersion.stable
was breaking the precision half of the time.Version.next_breaking
to allow for version withmajor == 0
Extra info
It would be great to have to have a
poetry build
step that checks therequires_dist
output against poetry to make sure the package is actually usable.