Skip to content

Raise a clearer error for a non-string TypedDict name - #828

Open
vmphase wants to merge 2 commits into
python:mainfrom
vmphase:fix/typeddict-typename
Open

vmphase wants to merge 2 commits into
python:mainfrom
vmphase:fix/typeddict-typename

Conversation

@vmphase

@vmphase vmphase commented Nov 20, 2026

Copy link
Copy Markdown

typing_extensions.TypedDict(3, {"a": int}) currently raises TypeError: can only assign string to Protocol.__name__, not 'int', meanwhile the stdlib raises TypeError: type.__new__() argument 1 must be str, not int. As far as I understand, the error comes from the placeholder name "Protocol" that _TypedDictMeta.__new__ uses internally, which is misleading.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant