Skip to content

Docs: improve generic typing.NamedTuple example #124739

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
merged 2 commits into from
Sep 29, 2024

Conversation

CBerJun
Copy link
Contributor

@CBerJun CBerJun commented Sep 29, 2024

  1. Generic typing.NamedTuple is not supported until Python 3.11, so class NT(NamedTuple, Generic[T]) won't work in versions lower than 3.11.
  2. Explicit T = TypeVar("T") is needed when using Generic[T].

📚 Documentation preview 📚: https://cpython-previews--124739.org.readthedocs.build/

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@AlexWaygood AlexWaygood added skip issue needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Sep 29, 2024
@AlexWaygood AlexWaygood merged commit 76fbee6 into python:main Sep 29, 2024
32 checks passed
@miss-islington-app
Copy link

Thanks @CBerJun for the PR, and @AlexWaygood for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 29, 2024
@bedevere-app
Copy link

bedevere-app bot commented Sep 29, 2024

GH-124764 is a backport of this pull request to the 3.13 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 29, 2024
@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 29, 2024
@bedevere-app
Copy link

bedevere-app bot commented Sep 29, 2024

GH-124765 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Sep 29, 2024
AlexWaygood pushed a commit that referenced this pull request Sep 29, 2024
…124765)

Docs: improve generic `typing.NamedTuple` example (GH-124739)
(cherry picked from commit 76fbee6)

Co-authored-by: CBerJun <[email protected]>
Yhg1s pushed a commit that referenced this pull request Sep 30, 2024
…124764)

Docs: improve generic `typing.NamedTuple` example (GH-124739)
(cherry picked from commit 76fbee6)

Co-authored-by: CBerJun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants