trycast
trycast copied to clipboard
Recognize generic TypedDicts, like Point[int]
Python 3.11 added support for generic TypedDicts.
For example, the following generic TypedDict can (probably) be defined now:
T = TypeVar('T', bound=Union[int, float, complex])
class Point(TypedDict, Generic[T]):
x: T
y: T
int_point: Point[int] = {"x": 1, "y": 2}
float_point: Point[float] = {"x": 1.0, "y": 2.0}
complex_point: Point[complex] = {"x": 1j, "y": 2j}
It would be nice if trycast() recognized parameterized TypedDict types like Point[int]