scverse_misc.deprecated_arg

Contents

scverse_misc.deprecated_arg#

scverse_misc.deprecated_arg(arg, msg, *, category=<class 'FutureWarning'>, stacklevel=1)#

Decorator to indicate that a function argument is deprecated.

Emits a warning when the decorated function is called with the deprecated argument and addtionally modifies the docstring to include a deprecation notice.

Parameters:
  • arg (LiteralString) – The deprecated argument.

  • msg (Deprecation) – The deprecation message.

  • category (type[Warning] (default: <class 'FutureWarning'>)) – The category of the warning that will be emitted at runtime.

  • stacklevel (int (default: 1)) – The stack level of the warning.

Return type:

Callable[[Callable[[ParamSpec(P)], TypeVar(R)]], Callable[[ParamSpec(P)], TypeVar(R)]]

Examples

>>> @deprecated_arg("bar", Deprecation("0.2", "The functionality has moved to the baz() function."))
... def foo(baz, bar=1):
...     pass