Skip to content

Commit d3bd245

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

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
@@ -2355,7 +2355,7 @@ These functions and classes should not be used directly as annotations.
23552355
Their intended purpose is to be building blocks for creating and declaring
23562356
types.
23572357

2358-
.. class:: NamedTuple
2358+
.. function:: NamedTuple
23592359

23602360
Typed version of :func:`collections.namedtuple`.
23612361

@@ -2428,6 +2428,10 @@ types.
24282428
Removed the ``_field_types`` attribute in favor of the more
24292429
standard ``__annotations__`` attribute which has the same information.
24302430

2431+
.. versionchanged:: 3.9
2432+
``NamedTuple`` is now a function rather than a class.
2433+
It can still be used as a class base, as described above.
2434+
24312435
.. versionchanged:: 3.11
24322436
Added support for generic namedtuples.
24332437

@@ -2584,10 +2588,10 @@ types.
25842588
for more details.
25852589

25862590

2587-
.. class:: TypedDict(dict)
2591+
.. function:: TypedDict
25882592

25892593
Special construct to add type hints to a dictionary.
2590-
At runtime it is a plain :class:`dict`.
2594+
At runtime ":class:`!TypedDict` instances" are simply :class:`dicts <dict>`.
25912595

25922596
``TypedDict`` declares a dictionary type that expects all of its
25932597
instances to have a certain set of keys, where each key is
@@ -2810,6 +2814,10 @@ types.
28102814

28112815
.. versionadded:: 3.8
28122816

2817+
.. versionchanged:: 3.9
2818+
``TypedDict`` is now a function rather than a class.
2819+
It can still be used as a class base, as described above.
2820+
28132821
.. versionchanged:: 3.11
28142822
Added support for marking individual keys as :data:`Required` or :data:`NotRequired`.
28152823
See :pep:`655`.

0 commit comments

Comments
 (0)