]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] Docs: improve generic `typing.NamedTuple` example (GH-124739) (#124764)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 30 Sep 2024 00:53:13 +0000 (02:53 +0200)
committerGitHub <noreply@github.com>
Mon, 30 Sep 2024 00:53:13 +0000 (17:53 -0700)
Docs: improve generic `typing.NamedTuple` example (GH-124739)
(cherry picked from commit 76fbee642e78eacf3866102f31e0ac969b57f1e6)

Co-authored-by: CBerJun <121291537+CBerJun@users.noreply.github.com>
Doc/library/typing.rst

index db41da60613e4d3d5861564b29de36cc4dc6925f..40df38c5503696aa61f4af1d464e025c455c0ee0 100644 (file)
@@ -2273,7 +2273,9 @@ types.
 
    Backward-compatible usage::
 
-       # For creating a generic NamedTuple on Python 3.11 or lower
+       # For creating a generic NamedTuple on Python 3.11
+       T = TypeVar("T")
+
        class Group(NamedTuple, Generic[T]):
            key: T
            group: list[T]