Eric V. Smith <e...@trueblade.com> added the comment:

Thanks for the report. This is the same error you get when using any non-field:

>>> @dataclass
... class C:
...   i: int
...
>>> c = C(4)
>>> replace(c, i=3)
C(i=3)
>>> replace(c, j=3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\home\eric\local\python\cpython\lib\dataclasses.py", line 1179, in 
replace
    return obj.__class__(**changes)
TypeError: __init__() got an unexpected keyword argument 'j'

I think the TypeError is correct in both cases. The error message might not be 
the best.

Are you suggesting that this shouldn't raise a TypeError? Since a ClassVar is 
not an instance variable, I don't think it makes any sense to replace() it.

----------

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

Reply via email to