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
It is a callable which produces a new pseudo-subtype of dict.
It can also be used as a base in the class statement for creating a new pseudo-subtype of dict.
In both cases it is not a real class. You cannot create an instance of TypedDict or its "subclass". isinstance() and issubclass() do not work with it. Instantiating it "subclass" always returns a dict. But it is implemented as a class, and help() shows methods and data descriptors for it, which are useless.
The proposed PR implements TypedDict as a function. It adds the __mro_entries__ method that allows to use it as a base in the class statement.
Activity
serhiy-storchaka commentedon Apr 4, 2020
typing.TypedDict is used in two ways.
In both cases it is not a real class. You cannot create an instance of TypedDict or its "subclass". isinstance() and issubclass() do not work with it. Instantiating it "subclass" always returns a dict. But it is implemented as a class, and help() shows methods and data descriptors for it, which are useless.
The proposed PR implements TypedDict as a function. It adds the __mro_entries__ method that allows to use it as a base in the class statement.
serhiy-storchaka commentedon Apr 4, 2020
See also bpo-40185.
serhiy-storchaka commentedon Apr 8, 2020
New changeset f228bf2 by Serhiy Storchaka in branch 'master':
bpo-40187: Refactor typing.TypedDict. (GH-19372)
f228bf2