-
Notifications
You must be signed in to change notification settings - Fork 96
VersionInfo.next_version() returns Union[VersionInfo, str] #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
Comments
Thanks @tlaferriere for your report! I think this is an oversight. From my understanding, the method should always return a VersionInfo object. We should ask @gsakkis, I guess you've intended to return a VersionInfo object all the time, am I right with this assumption? |
* Return VersionInfo instance in VersionInfo.next_version and not str when part is major, minor, or patch. * Change test_next_version_with_versioninfo Test for correct return type (should be VersionInfo) Co-authored-by: Thomas Laferriere <tlaferriere@users.noreply.github.com>
@tomschr indeed, this must have been a leftover from the very first version that returned always a string. |
Thanks George for conforming! 👍 I will create a 2.10.1 release soon. |
* Update CHANGELOG * Improve release-procedure.md * python-semver#249: Add release policy and version restriction in documentation to help our users which would like to stay on the major 2 release. * python-semver#250: Simplify installation semver on openSUSE with ``obs://``. * python-semver#251: Return type of ``semver.VersionInfo.next_version`` to always return a ``VersionInfo`` instance. * python-semver#256: Made docstrings consistent
VersionInfo.next_version()
return type is uncertain because at line 463 of semver.pyreturn version.replace(prerelease=None, build=None)
returns a VersionInfo object, whereas in line 466 it is explicitly converted tostr
and at line 470,version.bump_prerelease()
is documented withrtype: str
.This is problematic because if you call this on a version that has a prerelease or build number, you get a
VersionInfo
object, and otherwise you get astr
, and these two types must be handled quite differently.Personally, I would expect
VersionInfo.next_version()
to return aVersionInfo
object in all cases, but I think the main problem here is the ambiguity of the return type.The text was updated successfully, but these errors were encountered: