From abaf63e570b47efcfac11de082eb3a79387108e9 Mon Sep 17 00:00:00 2001 From: CBerJun Date: Sat, 28 Sep 2024 21:09:50 -0400 Subject: [PATCH 1/2] Docs: fix misleading information in generic `NamedTuple` example --- Doc/library/typing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 640bc2c9d503bc..623089bf83027e 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2349,7 +2349,7 @@ types. Backward-compatible usage:: - # For creating a generic NamedTuple on Python 3.11 or lower + # For creating a generic NamedTuple on Python 3.11 class Group(NamedTuple, Generic[T]): key: T group: list[T] From d064d316e7f57b4ae66701fee0ca0577e12eda4e Mon Sep 17 00:00:00 2001 From: CBerJun Date: Sat, 28 Sep 2024 21:29:35 -0400 Subject: [PATCH 2/2] Docs: add `TypeVar` definition in generic `NamedTuple` example --- Doc/library/typing.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 623089bf83027e..cd8b90854b0e94 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2350,6 +2350,8 @@ types. Backward-compatible usage:: # For creating a generic NamedTuple on Python 3.11 + T = TypeVar("T") + class Group(NamedTuple, Generic[T]): key: T group: list[T]