There's a PR for PEP 484 in the peps repo that has quite a bit of discussion in it:
The basic idea is to have a way to declare the type of a decorated function *after it's been decorated*, to serve as either documentation or a type hint in the case the decorator is untyped.
This is the full text of the paragraph that's being proposed as an addition to PEP 484:
Decorators
----------
Decorators can modify the types of the functions or classes they
decorate. Use the ``decorated_type`` decorator to declare the type of
the resulting item after all other decorators have been applied::
from typing import ContextManager, Iterator, decorated_type
from contextlib import contextmanager
class DatabaseSession: ...
@decorated_type(Callable[[str], ContextManager[DatabaseSession]])
@contextmanager
def session(url: str) -> Iterator[DatabaseSession]:
s = DatabaseSession(url)
try:
yield s
finally:
s.close()
The argument of ``decorated_type`` is a type annotation on the name
being declared (``session``, in the example above). If you have
multiple decorators, ``decorated_type`` must be topmost. The
``decorated_type`` decorator is invalid on a function declaration that
is also decorated with ``overload``, but you can annotate the
implementation of the overload series with ``decorated_type``.
This has been a "Work in Progress" PR since 2017. There are 40 comments but the last one is over two years old. I'm not sure that anybody really cares that much about this problem any more. Maybe we should just close it? Thoughts?