rbarrois / python-semanticversion

Semantic version comparison for Python (see http://semver.org/)
BSD 2-Clause "Simplified" License
281 stars 74 forks source link

next_major, next_minor do now work in case of partial versions #85

Closed regisz closed 4 years ago

regisz commented 5 years ago
semantic-version: 2.8.2
Python version: 3.5.6

A "-" sign is added at the end of version if I use next_major/next_minor in case of a partial version.

>>> from semantic_version import Version
>>> aa = Version("1.1.1", partial=True)
>>> aa.next_major()
Version('2.0.0-', partial=True)
>>> aa.next_minor()
Version('1.2.0-', partial=True)
>>> aa.next_patch()
Version('1.1.2-', partial=True)
rbarrois commented 5 years ago

Hi!

Thanks for the report, but I'm not sure about the behaviour you would expect to see?

partial=True versions are now deprecated, but they were meant to describe a simpler form of range descriptions - Version('1.0', partial=True) == v should now be replaced with v in SimpleSpec('=1.0').

However, if you're using Version(x, partial=True).next_major(), this would mean that I have missed some relevant use cases for them; could you detail what you're using them for? I wouldn't want to remove features simply because I wasn't aware of some interesting interactions!

regisz commented 5 years ago

Yes, I read about deprecated situation. But, now I use it :).

And, now, the next_major() adds a "-" at the end of the version, so: the wrong, actual case: Version("1.0.0", partial=True).next_major() -> Version("2.0.0-", partial=True) the expected case: Version("1.0.0", partial=True).next_major() -> Version("2.0.0", partial=True) (no -)

So, this wrong situation occurs if "partial=True" argument is used.

rbarrois commented 5 years ago

Indeed. What I'm interested into is: how/why/when do you use partial=True?

regisz commented 5 years ago

What I'm interested into is: how/why/when do you use partial=True?

:) I do it. Of course, I can workaround partial cases because finally a partial version becomes a completed version, so e.g. 1.0 will be 1.0.0. But, I am release manager in our firm, and we develop an own app to handle our releasing processes. And we use more version formats, and when I have to complete a partial version, then a nice solution to do it with object oriented style (uses classes, etc.), so I initialize the required class with a partial version string and after I call its complete() method. Partial version can come from branch names: in one of our repositories we use release/ terminology (release/9.1, release/9.2, etc.). And when I use version parts of these minor branch like a partial version, then possibility of partial version using helps for me. :)

rbarrois commented 5 years ago

Thanks for the details! Have you taken a look at Version.coerce()?

>>> Version.coerce('9.1')
Version('9.1.0')
regisz commented 5 years ago

Cool, it is useful for me (I did not know about this method), and I think I can solve the partial situations easily with this "trick" :). So, then I will be able to use the next major version of this package :).

rbarrois commented 4 years ago

This issue seems to have been fixed with some ad-hoc explanation; there is still an issue with the docs, hopefully the latest version is clearer here ;)