]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] Docs: improve generic `typing.NamedTuple` example (GH-124739) (#124765)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 29 Sep 2024 11:13:25 +0000 (13:13 +0200)
committerGitHub <noreply@github.com>
Sun, 29 Sep 2024 11:13:25 +0000 (11:13 +0000)
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 0bab1df6f4f254cbd79af9a41a88539e5edf82ca..8b464be14b059ee5a022fb95f2e43b4b9b7ae9c1 100644 (file)
@@ -2096,7 +2096,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]