laurent-laporte-pro / deprecated

Python @deprecated decorator to deprecate old python classes, functions or methods.
MIT License
307 stars 34 forks source link

Deprecated Decorator

Python @deprecated decorator to deprecate old python classes, functions or methods.

license GitHub release PyPI GitHub Workflow Status Coveralls branch Read the Docs (version)

Installation

pip install Deprecated

Usage

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

Authors

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.