You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python 3.13: TypedDict.__readonly_keys__ and __mutable_keys__ missing #18810
mypy doesn't synthesize the __readonly_keys__ and __mutable_keys__ class attributes of TypedDict, introduced in Python 3.13. This leads to stubtest complaining about each instance of a TypedDict due to the attributes missing from the stubs.
To Reproduce
# foo.pyfromtypingimportTypedDictclassFoo(TypedDict):
bar: strprint(Foo.__readonly_keys__) # at runtime: frozenset()print(Foo.__mutable_keys__) # at runtime: frozenset({'bar'})
Expected Behavior
Using mypy --python-version 3.13 foo.py: no errors.
Actual Behavior
foo.py:8: error: "type[Foo]" has no attribute "__readonly_keys__" [attr-defined]
foo.py:9: error: "type[Foo]" has no attribute "__mutable_keys__" [attr-defined]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
Mypy version used: 1.15.0
Mypy command-line flags: --python-version 3.13
Mypy configuration options from mypy.ini (and other config files): ./.
Activity
Ignore missing TypedDict fields
AlexWaygood commentedon Mar 17, 2025
Ah shoot, now that I look at this again, I think this is a typeshed bug? We should probably be listing these attributes in the
typing._TypedDictstub here: https://github.com/python/typeshed/blob/205e993b52681f14fe38f3790f88e39e7cf3474b/stdlib/typing.pyi#L945-L952same as we do in our stub for
typing_extensionshere: https://github.com/python/typeshed/blob/205e993b52681f14fe38f3790f88e39e7cf3474b/stdlib/typing_extensions.pyi#L225-L227srittau commentedon Mar 17, 2025
Good point, I'll send a PR. That will also make sure that it will work with any Python version.