xoutil.deprecation
- Utils for marking deprecated elements¶
-
xoutil.deprecation.
deprecated
(replacement, msg=None, deprecated_module=None, removed_in_version=None, check_version=False)[source]¶ Small decorator for deprecated functions.
Usage:
@deprecate(new_function) def deprecated_function(...): ...
Parameters: - replacement – Either a string or the object that replaces the deprecated.
- msg –
A deprecation warning message template. You should provide keyword arguments for the
format()
function. Currently we pass the current keyword arguments: replacement (after some processing), funcname with the name of the currently deprecated object and in_version with the version this object is going to be removed if removed_in_version argument is not None.Defaults to: “{funcname} is now deprecated and it will be removed{in_version}. Use {replacement} instead.”
- removed_in_version – The version the deprecated object is going to be removed.
- check_version –
If True and removed_in_version is not None, then declarations of obseleted objects will raise a DeprecationError. This helps the release manager to keep the release clean.
Note
Currently only works with setuptools’ installed distributions.
- deprecated_module – If provided, the name of the module the deprecated object resides. Not needed if the deprecated object is a function or class.
Changed in version 1.4.1: Introduces removed_in_version and check_version.