From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:13:25 +0000 (+0200) Subject: [3.12] Docs: improve generic `typing.NamedTuple` example (GH-124739) (#124765) X-Git-Tag: v3.12.7~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=980d4a1befe29b06d8af1ce82e70d983195e7b0e;p=thirdparty%2FPython%2Fcpython.git [3.12] Docs: improve generic `typing.NamedTuple` example (GH-124739) (#124765) Docs: improve generic `typing.NamedTuple` example (GH-124739) (cherry picked from commit 76fbee642e78eacf3866102f31e0ac969b57f1e6) Co-authored-by: CBerJun <121291537+CBerJun@users.noreply.github.com> --- diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 0bab1df6f4f2..8b464be14b05 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -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]