typing
typing copied to clipboard
(🎁) Allow usage of `TypedDict` as a type, such that it can be used in the `bound` of a `TypeVar`
from typing import Generic, TypedDict, TypeVar, Unpack
ExtraArgs = TypeVar("ExtraArgs", bound=TypedDict)
class A(Generic[ExtraArgs]):
def do_it(self, **extra: Unpack[ExtraArgs]): ...
class Thing(TypedDict):
t: int
A[Thing]().do_it(
t=1, # no error
imposter="sus", # yes error
)