A base type for annotations? #1543
Dreamsorcerer
started this conversation in
General
Replies: 2 comments
-
This was something I wanted to fix in a future pep for reified types |
Beta Was this translation helpful? Give feedback.
0 replies
-
This sounds like you want TypeForm: python/mypy#9773. That proposal hasn't progressed much, though. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I don't think this is possible currently, but it would be useful for Generics etc. if there was some way to specify
type[T]
for any valid annotation, to be used at runtime.For example, we have
aiohttp.web.AppKey
defined like:expected to be used like
AppKey("foo", int)
to define the type for the key (mostly imitating the design of TypeVar).The problem is that a lot of valid typing annotations are not actual 'types' and produce a typing error (e.g.
AppKey(..., Callable)
). There is probably some issue with making all of these compatible withtype
, but maybe we could introduce a new thing for types of typing constructs? Then we can annotate it liketype[T] | annotation_type[T]
or something.Beta Was this translation helpful? Give feedback.
All reactions