Author sigurd
Recipients eric.smith, sigurd
Date 2018-06-07.15:40:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1528386026.34.0.592728768989.issue33796@psf.upfronthosting.co.za>
In-reply-to
Content
I think you misunderstood the issue here. I'm not trying to replace the class variable itself, I'm changing another field on a class that has a class variable. The problem is that the replace method includes the class variable in the change dict when copying fields that are not included in the function call.

My call is: dataclasses.replace(obj, a=2) where I try to replace a, but it fails because class_var is included in the attributes to __init__ by the replace function.

The problem is on this line: https://github.com/python/cpython/blob/master/Lib/dataclasses.py#L1162
The _FIELDS attribute includes the class variable as a field, and it is therefore added to the changes dict.
History
Date User Action Args
2018-06-07 15:40:26sigurdsetrecipients: + sigurd, eric.smith
2018-06-07 15:40:26sigurdsetmessageid: <1528386026.34.0.592728768989.issue33796@psf.upfronthosting.co.za>
2018-06-07 15:40:26sigurdlinkissue33796 messages
2018-06-07 15:40:26sigurdcreate