-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-143728: Keep TypedDict and NamedTuple in class role in docs
#143702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlexWaygood
merged 3 commits into
python:main
from
johnslavik:set-namedtuple-and-typeddict-to-classes-in-docs
Jan 13, 2026
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
| Typed version of :func:`collections.namedtuple`. | ||
|
|
||
|
|
@@ -2589,7 +2589,7 @@ types. | |
| for more details. | ||
|
|
||
|
|
||
| .. function:: TypedDict | ||
| .. class:: TypedDict(dict) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would fix #143728, see |
||
|
|
||
| Special construct to add type hints to a dictionary. | ||
| At runtime ":class:`!TypedDict` instances" are simply :class:`dicts <dict>`. | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
NamedTuplewith the.. attribute::syntaxThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
NamedTuplein 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=codeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure
NamedTupleis likely to change, but I brought back the revert in 4244745.It seems to me that status quo is a safer approach.