Skip to content

Commit 0dc3c08

Browse files
miss-islingtonaiskAlexWaygood
authored
[3.13] gh-86139: Correct NamedTuple and TypedDict's type in typing.rst (GH-143692) (#143697)
Co-authored-by: AN Long <aisk@users.noreply.github.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
1 parent e319262 commit 0dc3c08

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Doc/library/typing.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ These functions and classes should not be used directly as annotations.
22572257
Their intended purpose is to be building blocks for creating and declaring
22582258
types.
22592259

2260-
.. class:: NamedTuple
2260+
.. function:: NamedTuple
22612261

22622262
Typed version of :func:`collections.namedtuple`.
22632263

@@ -2330,6 +2330,10 @@ types.
23302330
Removed the ``_field_types`` attribute in favor of the more
23312331
standard ``__annotations__`` attribute which has the same information.
23322332

2333+
.. versionchanged:: 3.9
2334+
``NamedTuple`` is now a function rather than a class.
2335+
It can still be used as a class base, as described above.
2336+
23332337
.. versionchanged:: 3.11
23342338
Added support for generic namedtuples.
23352339

@@ -2482,10 +2486,10 @@ types.
24822486
for more details.
24832487

24842488

2485-
.. class:: TypedDict(dict)
2489+
.. function:: TypedDict
24862490

24872491
Special construct to add type hints to a dictionary.
2488-
At runtime it is a plain :class:`dict`.
2492+
At runtime ":class:`!TypedDict` instances" are simply :class:`dicts <dict>`.
24892493

24902494
``TypedDict`` declares a dictionary type that expects all of its
24912495
instances to have a certain set of keys, where each key is
@@ -2708,6 +2712,10 @@ types.
27082712

27092713
.. versionadded:: 3.8
27102714

2715+
.. versionchanged:: 3.9
2716+
``TypedDict`` is now a function rather than a class.
2717+
It can still be used as a class base, as described above.
2718+
27112719
.. versionchanged:: 3.11
27122720
Added support for marking individual keys as :data:`Required` or :data:`NotRequired`.
27132721
See :pep:`655`.

0 commit comments

Comments
 (0)