New submission from Adrian Stachlewski <adrian.stachlew...@gmail.com>:
Class variables should behave in the same way whether with or without ClassVar annotation. Unfortunately there are not. class A: __slots__ = () x: ClassVar = set() A() # it's ok @dataclass class B: __slots__ = () x = set() B() # ok too @dataclass class C: __slots__ = () # cannot use set() because of error x: ClassVar = field(default_factory=set) C() # AttributeError: 'C' object has no attribute 'x' Exception is raised from __init__ method, with flag init=False nothing changes. Python version: 3.7.0b2 ---------- components: Library (Lib) messages: 314017 nosy: stachel priority: normal severity: normal status: open title: dataclasses: ClassVar attributes are not working properly type: behavior versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33094> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com