-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Closed
Labels
Description
Documentation
https://docs.python.org/3.12/library/typing.html#typing.TypedDict
Changed in version 3.11: Added support for generic TypedDicts.
The text description has already changed, too:
A TypedDict cannot inherit from a non-TypedDict class, except for Generic. For example:
class X(TypedDict):
x: int
class Y(TypedDict):
y: int
class Z(object): pass # A non-TypedDict class
class XY(X, Y): pass # OK
class XZ(X, Z): pass # raises TypeError
T = TypeVar('T')
class XT(X, Generic[T]): pass # raises TypeErrorOn the last line of the above code, # raises TypeError should be # OK. I have tested this in version 3.12. It is OK.
Linked PRs
- gh-107422: fix outdated docs example code of typing.TypedDict #107423
- gh-107422: Remove outdated
TypedDictexample from typing docs #107436 - [3.12] gh-107422: Remove outdated
TypedDictexample from typing docs (GH-107436) #107437 - [3.11] gh-107422: Remove outdated
TypedDictexample from typing docs (#107436) #107438