4.2. Replacing Deprecated FunctionsΒΆ
Changed in version 2.10.0: The development team of semver has decided to deprecate certain functions on
the module level. The preferred way of using semver is through the
Version
class.
The deprecated functions can still be used in version 2.10.0 and above. In version 3 of semver, the deprecated functions will be removed.
The following list shows the deprecated functions and how you can replace them with code which is compatible for future versions:
semver.bump_major()
,semver.bump_minor()
,semver.bump_patch()
,semver.bump_prerelease()
,semver.bump_build()
Replace them with the respective methods of the
Version
class. For example, the functionsemver.bump_major()
is replaced bybump_major()
and calling thestr(versionobject)
:>>> s1 = semver.bump_major("3.4.5") >>> s2 = str(Version.parse("3.4.5").bump_major()) >>> s1 == s2 True
Likewise with the other module level functions.
semver.Version.isvalid()
Replace it with
semver.version.Version.is_valid()
:semver.finalize_version()
Replace it with
semver.version.Version.finalize_version()
:>>> s1 = semver.finalize_version('1.2.3-rc.5') >>> s2 = str(semver.Version.parse('1.2.3-rc.5').finalize_version()) >>> s1 == s2 True
semver.format_version()
Replace it with
str(versionobject)
:>>> s1 = semver.format_version(5, 4, 3, 'pre.2', 'build.1') >>> s2 = str(Version(5, 4, 3, 'pre.2', 'build.1')) >>> s1 == s2 True
semver.max_ver()
Replace it with
max(version1, version2, ...)
ormax([version1, version2, ...])
and akey
:>>> s1 = semver.max_ver("1.2.3", "1.2.4") >>> s2 = max("1.2.3", "1.2.4", key=Version.parse) >>> s1 == s2 True
semver.min_ver()
Replace it with
min(version1, version2, ...)
ormin([version1, version2, ...])
:>>> s1 = semver.min_ver("1.2.3", "1.2.4") >>> s2 = min("1.2.3", "1.2.4", key=Version.parse) >>> s1 == s2 True
semver.parse()
Replace it with
semver.version.Version.parse()
and callsemver.version.Version.to_dict()
:>>> v1 = semver.parse("1.2.3") >>> v2 = Version.parse("1.2.3").to_dict() >>> v1 == v2 True
semver.parse_version_info()
Replace it with
semver.version.Version.parse()
:>>> v1 = semver.parse_version_info("3.4.5") >>> v2 = Version.parse("3.4.5") >>> v1 == v2 True
semver.replace()
Replace it with
semver.version.Version.replace()
:>>> s1 = semver.replace("1.2.3", major=2, patch=10) >>> s2 = str(Version.parse('1.2.3').replace(major=2, patch=10)) >>> s1 == s2 True