lisa.utils.deprecate#

lisa.utils.deprecate(msg=None, replaced_by=None, deprecated_in=None, removed_in=None, parameter=None)[source]#

Mark a class, method, function etc as deprecated and update its docstring.

Parameters:
  • msg (str or None) – Message to tell more about this deprecation.

  • replaced_by (object) – Other object the deprecated object is replaced by.

  • deprecated_in (str) – Version in which the object was flagged as deprecated.

  • removed_in (str) – Version in which the deprecated object will be removed.

  • parameter (str or None) – If not None, the deprecation will only apply to the usage of the given parameter. The relevant :param: block in the docstring will be updated, and the deprecation warning will be emitted anytime a caller gives a value to that parameter (default or not).

Note

In order to decorate all the accessors of properties, apply the decorator once the property is fully built:

class C:
    @property
    def foo(self):
        pass

    @foo.setter
    def foo(self, val):
        pass

    # Once all getters/setter/deleters are set, apply the decorator
    foo = deprecate()(foo)