trycast icon indicating copy to clipboard operation
trycast copied to clipboard

Recognize generic TypedDicts, like Point[int]

Open davidfstr opened this issue 3 months ago • 0 comments

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]

davidfstr avatar Mar 31 '24 15:03 davidfstr