Author eric.smith
Recipients eric.smith, stachel
Date 2018-03-19.01:15:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521422156.96.0.467229070634.issue33094@psf.upfronthosting.co.za>
In-reply-to
Content
There are a couple of problems here. You're using ClassVar incorrectly. It should be:

>>> @dataclass
... class C:
...   __slots__=()
...   x: ClassVar[int] = field(default=3)
... 
>>> C()
C()
>>> C.x
3


And you cannot have a ClassVar with a default_factory, since it would never get called:

>>> @dataclass
... class C:
...   __slots__=()
...   x: ClassVar[int] = field(default_factory=set)
... 

    raise TypeError(f'field {f.name} cannot have a '
TypeError: field x cannot have a default factory

Although this error message could be improved. Neither InitVars or ClassVars can have default factories.

I'm not exactly sure how to improve the error message that you're seeing.
History
Date User Action Args
2018-03-19 01:15:57eric.smithsetrecipients: + eric.smith, stachel
2018-03-19 01:15:56eric.smithsetmessageid: <1521422156.96.0.467229070634.issue33094@psf.upfronthosting.co.za>
2018-03-19 01:15:56eric.smithlinkissue33094 messages
2018-03-19 01:15:56eric.smithcreate