From 0fa65a26c3a6c6d107ecff348db5df21d9b9275b Mon Sep 17 00:00:00 2001 From: AN Long Date: Sun, 11 Jan 2026 23:59:32 +0900 Subject: [PATCH 1/4] Correct NamedTuple and TypedDict's type in typing.rst --- Doc/library/typing.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 4e9946fd4567cd..70d607f5673a64 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2369,7 +2369,7 @@ These functions and classes should not be used directly as annotations. Their intended purpose is to be building blocks for creating and declaring types. -.. class:: NamedTuple +.. function:: NamedTuple Typed version of :func:`collections.namedtuple`. @@ -2442,6 +2442,9 @@ types. Removed the ``_field_types`` attribute in favor of the more standard ``__annotations__`` attribute which has the same information. + .. versionchanged:: 3.9 + ``NamedTuple`` is now a function rather than a class. + .. versionchanged:: 3.11 Added support for generic namedtuples. @@ -2585,7 +2588,7 @@ types. for more details. -.. class:: TypedDict(dict) +.. function:: TypedDict Special construct to add type hints to a dictionary. At runtime it is a plain :class:`dict`. @@ -2811,6 +2814,9 @@ types. .. versionadded:: 3.8 + .. versionchanged:: 3.9 + ``TypedDict`` is now a function rather than a class. + .. versionchanged:: 3.11 Added support for marking individual keys as :data:`Required` or :data:`NotRequired`. See :pep:`655`. From 7ac42a3eec2f0784a67b066229bcdbd7832a2311 Mon Sep 17 00:00:00 2001 From: AN Long Date: Mon, 12 Jan 2026 00:07:58 +0900 Subject: [PATCH 2/4] Apply suggestion from @AlexWaygood Co-authored-by: Alex Waygood --- Doc/library/typing.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 70d607f5673a64..b77d55da6cefb5 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2444,6 +2444,7 @@ types. .. versionchanged:: 3.9 ``NamedTuple`` is now a function rather than a class. + It can still be used as a class base, as described above. .. versionchanged:: 3.11 Added support for generic namedtuples. From a60d2e51461f286869106a656db9588a1bb94e17 Mon Sep 17 00:00:00 2001 From: AN Long Date: Mon, 12 Jan 2026 00:09:02 +0900 Subject: [PATCH 3/4] Update by review comment --- Doc/library/typing.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index b77d55da6cefb5..37f2e7f4abac5d 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2817,6 +2817,7 @@ types. .. versionchanged:: 3.9 ``TypedDict`` is now a function rather than a class. + It can still be used as a class base, as described above. .. versionchanged:: 3.11 Added support for marking individual keys as :data:`Required` or :data:`NotRequired`. From 611ada7cdce153d4b551eb77401e013332c2226c Mon Sep 17 00:00:00 2001 From: AN Long Date: Mon, 12 Jan 2026 00:25:39 +0900 Subject: [PATCH 4/4] Update Doc/library/typing.rst Co-authored-by: Alex Waygood --- Doc/library/typing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 37f2e7f4abac5d..73236413cbb80f 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2592,7 +2592,7 @@ types. .. function:: TypedDict Special construct to add type hints to a dictionary. - At runtime it is a plain :class:`dict`. + At runtime ":class:`!TypedDict` instances" are simply :class:`dicts `. ``TypedDict`` declares a dictionary type that expects all of its instances to have a certain set of keys, where each key is