From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 30 Sep 2024 00:53:13 +0000 (+0200) Subject: [3.13] Docs: improve generic `typing.NamedTuple` example (GH-124739) (#124764) X-Git-Tag: v3.13.0rc3~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e532760f46957f867272dbbc5cc2bd779b5ac3a2;p=thirdparty%2FPython%2Fcpython.git [3.13] Docs: improve generic `typing.NamedTuple` example (GH-124739) (#124764) 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 db41da60613e..40df38c55036 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -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]