API

This part of the documentation covers all the interfaces of the Deprecated Library.

Deprecated decorator

Deprecated Library

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

deprecated.deprecated(reason)

This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.

Classic 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
Parameters:reason (str or callable or type) – Reason message (or function/class/method to decorate).