def deprecated(instead: Optional[str]=None) -> Callable[([Callable[(P, T)]], Callable[(P, T)])]:

    def actual_decorator(func: Callable[(P, T)]) -> Callable[(P, T)]:

        @functools.wraps(func)
        def decorated(*args: P.args, **kwargs: P.kwargs) -> T:
            warnings.simplefilter('always', DeprecationWarning)
            if instead:
                fmt = '{0.__name__} is deprecated, use {1} instead.'
            else:
                fmt = '{0.__name__} is deprecated.'
            warnings.warn(fmt.format(func, instead), stacklevel=3, category=DeprecationWarning)
            warnings.simplefilter('default', DeprecationWarning)
            return func(*args, **kwargs)
        return decorated
    return actual_decorator
def deprecated(instead: Optional[str]=None) -> Callable[([Callable[(P, T)]], Callable[(P, T)])]:

    def actual_decorator(func: Callable[(P, T)]) -> Callable[(P, T)]:

        @functools.wraps(func)
        def decorated(*args: P.args, **kwargs: P.kwargs) -> T:
            warnings.simplefilter('always', DeprecationWarning)
            if instead:
                fmt = '{0.__name__} is deprecated, use {1} instead.'
            else:
                fmt = '{0.__name__} is deprecated.'
            warnings.warn(fmt.format(func, instead), stacklevel=3, category=DeprecationWarning)
            warnings.simplefilter('default', DeprecationWarning)
            return func(*args, **kwargs)
        return decorated
    return actual_decorator