Python @deprecated
decorator to deprecate old python classes, functions or methods.
pip install Deprecated
To use this, decorate your deprecated function with @deprecated decorator:
from deprecated import deprecated
@deprecated
def some_old_function(x, y):
return x + y
You can also decorate a class or a method:
from deprecated import deprecated
class SomeClass(object):
@deprecated
def some_old_method(self, x, y):
return x + y
@deprecated
class SomeOldClass(object):
pass
You can give a "reason" message to help the developer to choose another function/class:
from deprecated import deprecated
@deprecated(reason="use another function")
def some_old_function(x, y):
return x + y
Have you ever wonder how to document that some functions, classes, methods, etc. are deprecated? This is now possible with the integrated Sphinx directives:
from deprecated.sphinx import deprecated
from deprecated.sphinx import versionadded
from deprecated.sphinx import versionchanged
@versionadded(version='1.0', reason="This function is new")
def function_one():
'''This is the function one'''
@versionchanged(version='1.0', reason="This function is modified")
def function_two():
'''This is the function two'''
@deprecated(version='1.0', reason="This function will be removed soon")
def function_three():
'''This is the function three'''
The authors of this library are: Marcos CARDOSO, and Laurent LAPORTE.
The original code was made in this StackOverflow post by Leandro REGUEIRO, Patrizio BERTONI, and Eric WIESER.