def deprecated(message, exception=PendingDeprecationWarning):
def decorator(func):<EOL><INDENT>@wraps(func)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>warnings.warn(message, exception, stacklevel=<NUM_LIT:2>)<EOL>return func(*args, **kwargs)<EOL><DEDENT>return wrapper<EOL><DEDENT>return decorator<EOL>
Throw a warning when a function/method will be soon deprecated

    Supports passing a ``message`` and an ``exception`` class
    (uses ``PendingDeprecationWarning`` by default). This is useful if you
    want to alternatively pass a ``DeprecationWarning`` exception for already
    deprecated functions/methods.

    Example::

        >>> import warnings
        >>> from functools import wraps
        >>> message = "this function will be deprecated in the near future"
        >>> @deprecated(message)
        ... def foo(n):
        ...     return n+n
        >>> with warnings.catch_warnings(record=True) as w:
        ...     warnings.simplefilter("always")
        ...     foo(4)
        ...     assert len(w) == 1
        ...     assert issubclass(w[-1].category, PendingDeprecationWarning)
        ...     assert message == str(w[-1].message)
        ...     assert foo.__name__ == 'foo'
        8