OK, I've closed the issue. Thanks for speaking up!

On Thu, Nov 7, 2019 at 3:40 AM Ivan Levkivskyi <levkivskyi@gmail.com> wrote:
I agree with Sebastian, the issue was probably relevant when mypy didn't have support for context managers, but now it is much less relevant.
Instead we should focus on adding support for variadic generics and argspecs.

--
Ivan



On Thu, 7 Nov 2019 at 08:23, Sebastian Rittau <srittau@rittau.biz> wrote:
Annotated functions whose signatures are modified by the decorator are still a problem with typing, but I feel we should work on improving the decorators themselves, instead.

 - Sebastian

Am 07.11.2019 05:08 schrieb Guido van Rossum <guido@python.org>:
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?

--
--Guido van Rossum (python.org/~guido)

_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/


--
--Guido van Rossum (python.org/~guido)
Pronouns: he/him (why is my pronoun here?)