deprecated_keyword_argument()

audeer.deprecated_keyword_argument(*, deprecated_argument, removal_version, new_argument=None, mapping=None, remove_from_kwargs=True)[source]

Mark keyword argument as deprecated.

Provide a decorator to mark keyword arguments as deprecated.

You have to specify the version, for which the deprecated argument will be removed. The content assigned to deprecated_argument is passed on to the new_argument.

Parameters
  • deprecated_argument (str) – keyword argument to be marked as deprecated

  • removal_version (str) – version the code will be removed

  • new_argument (Optional[str]) – keyword argument that should be used instead

  • mapping (Optional[Callable]) – if the keyword argument is not only renamed, but expects also different input values, you can map to the new ones with this callable

  • remove_from_kwargs (bool) – if True, deprecated_argument will be removed from kwargs inside the decorated object

Return type

Callable

Examples

>>> @deprecated_keyword_argument(
...     deprecated_argument="foo",
...     new_argument="bar",
...     removal_version="2.0.0",
... )
... def function_with_new_argument(*, bar):
...     pass