Skip to content

Commit 6dd6fe4

Browse files
Specs clarification: Forbid ClassVar and Final within TypedDict body (#1890)
1 parent d1e4add commit 6dd6fe4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

docs/spec/class-compat.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ annotated in ``__init__`` or other methods, rather than in the class::
8989
def __init__(self, content):
9090
self.content: T = content
9191

92+
``ClassVar`` cannot be used as a qualifier for a :ref:`TypedDict <typeddict>`
93+
item or a :ref:`NamedTuple <namedtuple>` field. Such usage also generates
94+
an error at runtime.
95+
9296
.. _`override`:
9397

9498
``@override``

docs/spec/qualifiers.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ following should be allowed::
203203
Y: Final = "y"
204204
N = NamedTuple("N", [(X, int), (Y, int)])
205205

206+
``Final`` cannot be used as a qualifier for a :ref:`TypedDict <typeddict>`
207+
item or a :ref:`NamedTuple <namedtuple>` field. Such usage also generates
208+
an error at runtime.
209+
206210
.. _`annotated`:
207211

208212
``Annotated``

0 commit comments

Comments
 (0)