Skip to content
Merged
Changes from 1 commit
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
4 changes: 2 additions & 2 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.

.. function:: NamedTuple
.. class:: NamedTuple
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this one need to change? I don't think we have any attributes documented for NamedTuple with the .. attribute:: syntax

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. class:: NamedTuple
.. function:: NamedTuple

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this changes in the future, and we would then need to change the type again? My only concern is that changing the type results in warnings/errors for anyone referencing NamedTuple in their docs, so maybe we need to be careful when changing such types.

First example that came to mind was the peps repo, with some hits for TypedDict: https://github.com/search?q=repo%3Apython%2Fpeps+%2F%3Aclass%3A%60%28%28%7E%29%3Ftyping%5C.%29%3FTypedDict%2F&type=code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure NamedTuple is likely to change, but I brought back the revert in 4244745.
It seems to me that status quo is a safer approach.


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

Expand Down Expand Up @@ -2589,7 +2589,7 @@ types.
for more details.


.. function:: TypedDict
.. class:: TypedDict(dict)
Copy link
Copy Markdown
Member

@sobolevn sobolevn Jan 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would fix #143728, see https://docs.python.org/3.15/library/typing.html#typing.__total__


Special construct to add type hints to a dictionary.
At runtime ":class:`!TypedDict` instances" are simply :class:`dicts <dict>`.
Expand Down
Loading