Author stachel
Recipients stachel
Date 2018-03-17.23:03:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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

class B:
    __slots__ = ()
    x = set()

B()  # ok too

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:50stachelsetrecipients: + stachel
2018-03-17 23:03:50stachelsetmessageid: <>
2018-03-17 23:03:50stachellinkissue33094 messages
2018-03-17 23:03:50stachelcreate