Guido van Rossum <gu...@python.org> added the comment:

> > I liked the original design better, where things without annotations would 
> > just be ignored. What changed?

> With the original proposal the ignored variables without annotations will 
> behave as class variables. This "conflicts" with PEP 526 which requires class 
> variables to be annotated with ClassVar[...]. On the other hand some people 
> may be unhappy that they need to import `typing` to define a class variable 
> in a dataclass. So this is a convenience vs consistence question. I am more 
> in favour of consistence here, but only +0.

There is no real conflict with PEP 526 though. PEP 526 introduces ClassVar so 
the type checker can be made to understand. PEP 557 allows omitting ClassVar in 
case you don't care about type checkers. So I think we should stick with the 
current spec of PEP 557 (which lets you omit ClassVar), except for this special 
case:

> I still think that flagging this
> 
> @dataclass
> class C:
>     x = field()
> 
> is important, since simply ignoring a ``field()`` will be too confusing 
> (especially for ``attrs`` users).

Agreed. That's a special case and I'm fine with flagging it as an error.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32428>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to