Skip to content

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

License

Notifications You must be signed in to change notification settings

laurent-laporte-pro/deprecated

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3f67ca7 · Jan 27, 2025
Jan 24, 2025
Jan 27, 2025
Jan 27, 2025
Nov 15, 2024
Jan 27, 2025
Apr 10, 2020
Jan 24, 2025
Dec 11, 2024
Jan 24, 2025
Jan 27, 2025
Nov 15, 2024
Jul 8, 2018
Apr 5, 2020
Nov 20, 2017
Nov 15, 2024
May 27, 2023
Jan 27, 2025
Jun 2, 2021
Jan 27, 2025
Jan 24, 2025

Repository files navigation

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.