Typing and Generics
typing.ClassVar
Signals that an attribute belongs to the class rather than individual instances for static checking. It neither changes attribute lookup nor prevents instance assignment at runtime.
Formal Syntax & Structure
python syntaxpython
typing.ClassVar[T]Return Value
type qualifier
Typing construct or runtime result as described; static typing rules are not runtime validation.
Working Example
Example Snippetpython
from typing import ClassVar, Counter
class Counter: total: ClassVar[int] = 3print((Counter.total, Counter().total))