From 6dd6fe403634ac5c89849e57141bcbc116ee2831 Mon Sep 17 00:00:00 2001 From: InSync Date: Sun, 8 Dec 2024 07:43:41 +0700 Subject: [PATCH] Specs clarification: Forbid `ClassVar` and `Final` within `TypedDict` body (#1890) --- docs/spec/class-compat.rst | 4 ++++ docs/spec/qualifiers.rst | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/spec/class-compat.rst b/docs/spec/class-compat.rst index 9f88d564..f3086e75 100644 --- a/docs/spec/class-compat.rst +++ b/docs/spec/class-compat.rst @@ -89,6 +89,10 @@ annotated in ``__init__`` or other methods, rather than in the class:: def __init__(self, content): self.content: T = content +``ClassVar`` cannot be used as a qualifier for a :ref:`TypedDict ` +item or a :ref:`NamedTuple ` field. Such usage also generates +an error at runtime. + .. _`override`: ``@override`` diff --git a/docs/spec/qualifiers.rst b/docs/spec/qualifiers.rst index 4a3bcc9f..7ba4d9f4 100644 --- a/docs/spec/qualifiers.rst +++ b/docs/spec/qualifiers.rst @@ -203,6 +203,10 @@ following should be allowed:: Y: Final = "y" N = NamedTuple("N", [(X, int), (Y, int)]) +``Final`` cannot be used as a qualifier for a :ref:`TypedDict ` +item or a :ref:`NamedTuple ` field. Such usage also generates +an error at runtime. + .. _`annotated`: ``Annotated``