Skip to the content.

Type Hint for Class Variables: typing.ClassVar

Recipes

Special type construct to mark class variables.

from typing import ClassVar

class C:
    cls_attr: ClassVar[dict[str, int]] = {}   # class variable
    ins_attr: int = 10                        # instance variable

More Details

References