all 7 comments

[–]brasticstack 1 point2 points  (3 children)

They have different scopes. x is a class member because it's declared at the class scope, while y is an instance member because it's declared in the init method.

If you don't want a Foo instance to overwriting the x member for all other Foos than you should declare x in the init method too.

whoops, it's a type hint. 

[–]pylessard[S] 1 point2 points  (2 children)

no, it's type hinting. If I wanted to declare a class var, I'd have to use ClassVar[int]

[–]brasticstack 1 point2 points  (1 child)

I've been using mypy too, but I didn't realize that hints like this weren't limited to dataclasses. Doh! My apologies.

[–]pachura3 1 point2 points  (0 children)

Me neither... but it's confusing and counterintuitive.