Message314017
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 |
|
Date |
User |
Action |
Args |
2018-03-17 23:03:50 | stachel | set | recipients:
+ stachel |
2018-03-17 23:03:50 | stachel | set | messageid: <1521327830.3.0.467229070634.issue33094@psf.upfronthosting.co.za> |
2018-03-17 23:03:50 | stachel | link | issue33094 messages |
2018-03-17 23:03:50 | stachel | create | |
|