Skip to content

Commit

Permalink
Specs clarification: Forbid ClassVar and Final within TypedDict
Browse files Browse the repository at this point in the history
… body (#1890)
  • Loading branch information
InSyncWithFoo authored Dec 8, 2024
1 parent d1e4add commit 6dd6fe4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/spec/class-compat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typeddict>`
item or a :ref:`NamedTuple <namedtuple>` field. Such usage also generates
an error at runtime.

.. _`override`:

``@override``
Expand Down
4 changes: 4 additions & 0 deletions docs/spec/qualifiers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typeddict>`
item or a :ref:`NamedTuple <namedtuple>` field. Such usage also generates
an error at runtime.

.. _`annotated`:

``Annotated``
Expand Down

0 comments on commit 6dd6fe4

Please sign in to comment.