import warnings


def deprecated(message=None):
    """
    Return a decorator that wraps a function with the given warning
    message.
    """
    def mk_deprecated_wrapper(function):
        msg = (message
               if message is not None
               else f'`{function.__module__}.{function.__name__}` '
               'is deprecated')
        def wrap_deprecated(*args, **kwds):
            warnings.warn(DeprecationWarning(msg), stacklevel=2)
            return function(*args, **kwds)
        return wrap_deprecated
    return mk_deprecated_wrapper