You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As someone who contributes to a project that uses this library I have to say that I disagree with these deprecations. Replacing semver.compare(version1, version2) with semver.VersionInfo.parse(version1).compare(version2) is just an ugly solution. The first one is clean, easy to read and easy to understand. The second one is ugly, and unnecessarily verbose.
I think your refactor to use VersionInfo under the hood is a great solution, but I don't see why the compare convenience function needs to become deprecated in the process. I would guess that most use cases of this library are fairly simple, as is the case for my project, and for those use cases semver.compare is objectively better.
Let me counter @scls19fr 's comment with this:
Python is not Java. You do not need to make everything a class.
Of course, it depends on your taste if you think this is still "ugly" or "readable".
Python is not Java. You do not need to make everything a class.
To be precise, he compared Python with Julia, not Java. I agree, not everything needs to be a class in Python. In this case, I still think a version class has some advantages over a string-only representation.
The current implementation delegates everything inside the module-level functions to the VersionInfo class. In this design, the module-level functions act as a "wrapper". So with the current version 2.10.1, you use the class anyway. These wrappers do some internal conversions to be compatible with the existing API.
[...] but I don't see why the compare convenience function needs to become deprecated in the process.
It's Python itself in its Zen where it states: "There should be one--and preferably only one--obvious way to do it."
Nothing will change in regards to the module-level functions. They stay as they are.
With major 3 I've planned to keep them for some more releases, let's say 3.1, to make the transition a bit easier. However, after some time, I plan to remove them.
Currently, you are the first one to raise this concern. Either others are not aware of this or they think this is not that important. If more developers raise concern and would like to keep them, we could reconsider it. However, in that case, please open a new issue where we can discuss this in a new, fresh environment.
I know that I can implement my own workaround to make the code more pretty. I could just copy and paste the compare function somewhere in my codebase too. For now I've decided to pin at version 2.9 since I'm trying to get rid of warnings from my codebase. My use case is very simple, used only to support certain legacy software, and I don't expect to need any new features that may come in newer versions of semver. Hopefully I can drop the dependency completely at some point.
I don't know about the other functions but I think you should at least consider keeping compare as it represents one of the the most basic (and maybe common) use cases of this library. I'll also point out that the readme still recommends using compare:
To compare two versions, semver provides the semver.compare function.
As for the "python is not X" thing. I'm just trying to say that I think statements like that are pretty meaningless because you can always just plug in a different language and make the opposite argument.
For now I've decided to pin at version 2.9 since I'm trying to get rid of warnings from my codebase.
Shouldn't be necessary, you can suppress only the semver warnings too. Use a warning filter as described in the warnings module of the Python documentation.
I don't know about the other functions but I think you should at least consider keeping compare as it represents one of the the most basic (and maybe common) use cases of this library.
Could you open a new issue for that, please? Thanks!
I'll also point out that the readme still recommends using compare:
Ahh, thanks! 👍 That was the missing part from the refactoring.
As for the "python is not X" thing. I'm just trying to say that I think statements like that are pretty meaningless because you can always just plug in a different language and make the opposite argument.
I'm not sure if I completely understood your sentence. We are talking about Python only.
Of course it's not a strict law, but a rule of thumb to help deciding things. Lots of projects and developers align themselves to these rules. It's not really surprising, it belongs to Python's core philosophy.
Activity
s-celles commentedon Apr 18, 2020
No objection. Python is not Julia. So let's prefer methods instead over functions.
[-]Deprecate semver.match?[/-][+]Deprecate missing module-level functions (like semver.compare, semver.match, ...)[/+]Fix python-semver#236: add missing deprecated functions
Merge pull request #239 from tomschr/bugfix/236-deprecate-others
Askaholic commentedon May 17, 2020
As someone who contributes to a project that uses this library I have to say that I disagree with these deprecations. Replacing
semver.compare(version1, version2)withsemver.VersionInfo.parse(version1).compare(version2)is just an ugly solution. The first one is clean, easy to read and easy to understand. The second one is ugly, and unnecessarily verbose.I think your refactor to use
VersionInfounder the hood is a great solution, but I don't see why thecompareconvenience function needs to become deprecated in the process. I would guess that most use cases of this library are fairly simple, as is the case for my project, and for those use casessemver.compareis objectively better.Let me counter @scls19fr 's comment with this:
Python is not Java. You do not need to make everything a class.
tomschr commentedon May 17, 2020
Thanks @Askaholic I appreciate your feedback. 👍
Well, it's a bit late after almost everything has been refactored and so much effort went into that. 😉
I know, some parts may be verbose. If you need the
comparefunction more often, it could be done in a less verbose variant like this:Of course, it depends on your taste if you think this is still "ugly" or "readable".
To be precise, he compared Python with Julia, not Java. I agree, not everything needs to be a class in Python. In this case, I still think a version class has some advantages over a string-only representation.
The current implementation delegates everything inside the module-level functions to the VersionInfo class. In this design, the module-level functions act as a "wrapper". So with the current version 2.10.1, you use the class anyway. These wrappers do some internal conversions to be compatible with the existing API.
It's Python itself in its Zen where it states: "There should be one--and preferably only one--obvious way to do it."
For your information, if you really dislike this change, you can still stay with major release 2 as described in https://python-semver.readthedocs.io/en/latest/install.html#release-policy
Nothing will change in regards to the module-level functions. They stay as they are.
With major 3 I've planned to keep them for some more releases, let's say 3.1, to make the transition a bit easier. However, after some time, I plan to remove them.
Currently, you are the first one to raise this concern. Either others are not aware of this or they think this is not that important. If more developers raise concern and would like to keep them, we could reconsider it. However, in that case, please open a new issue where we can discuss this in a new, fresh environment.
Askaholic commentedon May 17, 2020
@tomschr Thanks for the response!
I know that I can implement my own workaround to make the code more pretty. I could just copy and paste the
comparefunction somewhere in my codebase too. For now I've decided to pin at version2.9since I'm trying to get rid of warnings from my codebase. My use case is very simple, used only to support certain legacy software, and I don't expect to need any new features that may come in newer versions of semver. Hopefully I can drop the dependency completely at some point.I don't know about the other functions but I think you should at least consider keeping
compareas it represents one of the the most basic (and maybe common) use cases of this library. I'll also point out that the readme still recommends usingcompare:As for the "python is not X" thing. I'm just trying to say that I think statements like that are pretty meaningless because you can always just plug in a different language and make the opposite argument.
tomschr commentedon May 18, 2020
@Askaholic
Shouldn't be necessary, you can suppress only the semver warnings too. Use a warning filter as described in the warnings module of the Python documentation.
Could you open a new issue for that, please? Thanks!
Ahh, thanks! 👍 That was the missing part from the refactoring.
I'm not sure if I completely understood your sentence. We are talking about Python only.
Of course it's not a strict law, but a rule of thumb to help deciding things. Lots of projects and developers align themselves to these rules. It's not really surprising, it belongs to Python's core philosophy.