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. However, in future versions of semver, the deprecated functions will be removed.
4.2.1. Deprecated Module Level Functions¶
The following list shows the deprecated module level 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_buildReplace them with the respective methods of the
Versionclass. For example, the functionsemver.bump_majoris replaced byVersion.bump_majorand 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.
-
Replace it with
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
-
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
-
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
-
Replace it with
min(version1, version2, ...)ormin([version1, version2, ...])and akey:>>> s1 = semver.min_ver("1.2.3", "1.2.4") >>> s2 = min("1.2.3", "1.2.4", key=Version.parse) >>> s1 == s2 True
-
Replace it with
Version.parseand callVersion.to_dict:>>> v1 = semver.parse("1.2.3") >>> v2 = Version.parse("1.2.3").to_dict() >>> v1 == v2 True
-
Replace it with
Version.parse:>>> v1 = semver.parse_version_info("3.4.5") >>> v2 = Version.parse("3.4.5") >>> v1 == v2 True
-
Replace it with
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
4.2.2. Deprected Version methods¶
The following list shows the deprecated methods of the Version class.
Version.isvalidReplace it with
Version.is_valid:
4.2.3. Deprecated Classes¶
-
The class was renamed to
Version. Don’t use the old name anymore.