Currently we treat Annotated like any other annotation, but it probably makes sense to at the very least treat the second item in the subscript argument differently, since it is intended to encapsulate arbitrary values, which will likely be accessed at runtime.
So we should treat Annotated itself and the entire expression of the second item as a soft-runtime use. I'm torn about whether we should treat the first item as a soft-runtime use as well. On the one hand it will be necessary to make typing.get_type_hints work, on the other hand, there's less of a reason to use typing.get_type_hints when only trying to retrieve the second item of Annotated. Maybe this should be a setting?
One big caveat of this special casing is, that we may not have a good way of extracting Annotated from quoted annotations, so the special casing would probably be inconsistent between quoted and unquoted annotations, if this causes problems it may provide a compelling reason to actually start parsing the annotation expressions, instead of doing a simplified name extraction.
This was partially implemented in #193 but we probably want to add soft-runtime uses for the names in the value expression and add a couple of additional test cases.
Currently we treat
Annotated
like any other annotation, but it probably makes sense to at the very least treat the second item in the subscript argument differently, since it is intended to encapsulate arbitrary values, which will likely be accessed at runtime.So we should treat
Annotated
itself and the entire expression of the second item as a soft-runtime use. I'm torn about whether we should treat the first item as a soft-runtime use as well. On the one hand it will be necessary to maketyping.get_type_hints
work, on the other hand, there's less of a reason to usetyping.get_type_hints
when only trying to retrieve the second item ofAnnotated
. Maybe this should be a setting?One big caveat of this special casing is, that we may not have a good way of extracting
Annotated
from quoted annotations, so the special casing would probably be inconsistent between quoted and unquoted annotations, if this causes problems it may provide a compelling reason to actually start parsing the annotation expressions, instead of doing a simplified name extraction.