This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Refactor typing.TypedDict
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, levkivskyi, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-04-04 21:20 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19372 merged serhiy.storchaka, 2020-04-04 21:23
Messages (3)
msg365786 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-04-04 21:20
typing.TypedDict is used in two ways.

1. It is a callable which produces a new pseudo-subtype of dict.
2. 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.
msg365787 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-04-04 21:21
See also issue40185.
msg365973 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-04-08 08:03
New changeset f228bf2300a9d3bf833b1a89336581822e864ae5 by Serhiy Storchaka in branch 'master':
bpo-40187: Refactor typing.TypedDict. (GH-19372)
https://github.com/python/cpython/commit/f228bf2300a9d3bf833b1a89336581822e864ae5
History
Date User Action Args
2022-04-11 14:59:29adminsetgithub: 84368
2020-04-08 08:05:53serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-04-08 08:03:32serhiy.storchakasetmessages: + msg365973
2020-04-04 21:23:04serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request18734
2020-04-04 21:21:13serhiy.storchakasetmessages: + msg365787
2020-04-04 21:20:39serhiy.storchakacreate