I agree with this idea: Annotated is meant for typing and non-typing use cases of annotations to coexist, so we should make sure that it can be used in any annotation seamlessly.

El mar, 8 feb 2022 a las 12:40, Gregory Beauregard via Typing-sig (<typing-sig@python.org>) escribió:
Recently, we fixed Annotated so that it is allowed to wrap Final and ClassVar[1]. Since then I have found a number of other places where Annotated cannot wrap typeforms at runtime. In an issue addressing that ParamSpec P.args and P.kwargs cannot be wrapped at runtime [2], it was brought up that one might not consider these types and thus they might contravene the PEP 593 (Annotated)[3] statement "The first argument to Annotated must be a valid type" and thus we should discuss it publicly.

It is my position that the PEP never intended to disallow using Annotated on top-level typeforms (like P.args and P.kwargs), and that moreover the intention either always was or should be that if an Annotated contains something that would be a valid typeform in that location, it's a valid place to use Annotated. If we look back on the typing issue [4] that discussed adding Annotated, the requirement is worded that the first Annotated argument must be a "valid `typing` type" as opposed to a type in some stricter understanding of the term. A stronger argument I think is in the impetus of the PEP itself: the PEP is intended to allow typing and non-typing users of annotation space in Python to coexist. If the PEP intended to completely disallow Annotated to be used in certain annotation spots, the PEP isn't accomplishing one of its primary stated intentions.

Is there agreement that Annotated should be allowed in these locations?

I will submit appropriate doc/runtime changes given agreement.

[1] https://bugs.python.org/issue46491
[2] https://bugs.python.org/issue46643
[3] https://www.python.org/dev/peps/pep-0593/
[4] https://github.com/python/typing/issues/600
_______________________________________________
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/
Member address: jelle.zijlstra@gmail.com