Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize generic TypedDicts, like Point[int] #28

Open
davidfstr opened this issue Mar 31, 2024 · 0 comments
Open

Recognize generic TypedDicts, like Point[int] #28

davidfstr opened this issue Mar 31, 2024 · 0 comments
Labels
feature New feature or request
Milestone

Comments

@davidfstr
Copy link
Owner

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 davidfstr added this to the Someday milestone Mar 31, 2024
@davidfstr davidfstr added the feature New feature or request label Mar 31, 2024
@davidfstr davidfstr modified the milestones: Someday, v1.3 Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant