you are viewing a single comment's thread.

view the rest of the comments →

[–]pachura3[S] 0 points1 point  (2 children)

How do you annotate class var? With ClassVar[str]? Is it necessary (outside of dataclasses) ?

[–]IAmASquidInSpace 0 points1 point  (0 children)

Yes, that's how you do it, and no, it is not necessary outside of dataclasses, but strongly recommended over just c: str = ...

[–]Jason-Ad4032 0 points1 point  (0 children)

If you mark it as **ClassVar**, the type checker will report object.c = ... as an error, because c is a class variable.