-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-92106: Forbid specialization of TypedDict types #92116
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
gh-92106: Forbid specialization of TypedDict types #92116
Conversation
Cc. @davidfstr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems nice and simple, and it does indeed make no sense from a typing perspective to try to parameterise a non-generic TypedDict
This could break users who want to use generic TypedDicts compatible with pre-3.11: if TYPE_CHECKING:
class TD(TypedDict, Generic[T]):
a: T
else:
class TD(TypedDict):
a: T
d: TD[int] = {"a": 1} I think it's safer to keep things unchanged here. |
Agreed. Also, this PR appears to conflict with #27663 , which seems likely to be merged soon. |
Forbidding parametrization of non-generic TypedDict types is a side effect of #27663. I created a separate issue to make it clear. If we agree that it should forbidden, we should merge this PR (which also includes tests). If we agree that it should be allowed, we should add other tests, explicitly document this behavior, and change #27663 to keep non-generic TypedDict types parametrizable. |
Why not write |
That would work, but it would be a backward compatibility break. We should let code work on 3.11 unchanged if possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's instead test that subscription works on arbitrary TypedDicts.
When you're done making the requested changes, leave the comment: And if you don't make the requested changes, you will be poked with soft cushions! |
Closing in favor of #92176. |
Closes #92106.