Author eric.smith
Recipients eric.smith, rhettinger
Date 2018-02-25.22:29:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1519597763.79.0.467229070634.issue32953@psf.upfronthosting.co.za>
In-reply-to
Content
A related issue is that dataclasses derived from frozen dataclasses are automatically "promoted" to being frozen.

>>> @dataclass(frozen=True)
... class A:
...     i: int
...
>>> @dataclass
... class B(A):
...     j: int
...
>>> b = B(1, 2)
>>> b.j = 3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\home\eric\local\python\cpython\lib\dataclasses.py", line 452, in _frozen_setattr
    raise FrozenInstanceError(f'cannot assign to field {name!r}')
dataclasses.FrozenInstanceError: cannot assign to field 'j'

If this can't be addressed before 3.7, maybe it should be an error to declare B as non-frozen and then we can properly fix it in a future release.
History
Date User Action Args
2018-02-25 22:29:23eric.smithsetrecipients: + eric.smith, rhettinger
2018-02-25 22:29:23eric.smithsetmessageid: <1519597763.79.0.467229070634.issue32953@psf.upfronthosting.co.za>
2018-02-25 22:29:23eric.smithlinkissue32953 messages
2018-02-25 22:29:23eric.smithcreate