Deprecate module level functions#229
Merged
tomschr merged 1 commit intopython-semver:masterfrom Apr 16, 2020
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #225.
For example, the
VersionInfo.bump_major()method callssemver.parse_version_infoandsemver.bump_majorinstead of having its own implementation. This has several drawbacks:As such, I had to move some implementation into the
VersionInfoclass. With this approach, we can deprecate the module level function without triggering a false positive when calling a method inVersionInfo.This PR contains the following changes:
Add test cases
finalize_versionpytest.warnsinstead of justpytest.deprecated_callIn
setup.cfg, add deprecation warnings filter for pytestImplement DeprecationWarning with warnings module and the new decorator
deprecatedOutput a DeprecationWarning for the following functions:
semver.bump_{major,minor,patch,prerelease,build}semver.finalize_versionsemver.format_versionsemver.parsesemver.parse_version_infosemver.replaceMove module level implementation into
VersionInfoMove implementations:
semver.format_version->semver.VersionInfo.format_versionsemver.VersionInfo.__str___REGEXintoVersionInfoclass_LAST_NUMBERintoVersionInfoclass_increment_stringand implement it as a staticmethodsemver.parse->semver.VersionInfo.parsesemver.bump_*->semver.VersionInfo.bump_*Change implementation by calling VersionInfo methods (and not the other way around):
semver.comparesemver.finalize_versionsemver.replacesemver.parse_version_infoIntroduce new public functions:
semver.VersionInfo.to_dict(from former_asdict)semver.VersionInfo.to_tuple(from former_astuple)_asdictand_astupleas a (deprecated) function for compatibility reasonsUpdate CHANGELOG.rst
Update usage documentation:
- Move some information to make them more useful for the reader
- Add deprecation warning
- Explain how to replace deprecated functions
- Explain how to display deprecation warnings from semver
Improve documentation of deprecated functions
@gsakkis As you were also involved, I'd like to hear your opinion too. 😉