I’m trying to create a TypeVar
that is limited to TypedDict
. When I try TV = TypeVar("TV", bound=TypedDict)
, I see type checker (mypy) error: Variable "typing.TypedDict" is not valid as a type [valid-type]
.
When I look at typing
source code, I see that TypedDict
is a function, not a class.
How to create a type variable that can only accept TypedDict
type? And how does inheriting a function even work?