Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down Expand Up @@ -2442,6 +2442,10 @@ 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.
It can still be used as a class base, as described above.

.. versionchanged:: 3.11
Added support for generic namedtuples.

Expand Down Expand Up @@ -2585,10 +2589,10 @@ 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`.
At runtime ":class:`!TypedDict` instances" are simply :class:`dicts <dict>`.

``TypedDict`` declares a dictionary type that expects all of its
instances to have a certain set of keys, where each key is
Expand Down Expand Up @@ -2811,6 +2815,10 @@ types.

.. versionadded:: 3.8

.. 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`.
See :pep:`655`.
Expand Down
Loading