Message392174
from dataclasses import dataclass, replace
@dataclass()
class A:
a: int
class B(A):
def __init__(self):
super().__init__(a=1)
obj1 = B()
obj2 = replace(obj1, a=2)
File "/usr/lib/python3.9/dataclasses.py", line 1284, in replace
return obj.__class__(**changes)
TypeError: __init__() got an unexpected keyword argument 'a'
When a class extends a dataclass and overrides `__init__`, `replace` still accepts it as a dataclass according to the PEP but fails at constructing, since the `__init__`-signature doesn't match anymore. |
|
Date |
User |
Action |
Args |
2021-04-28 09:34:28 | SebastianSpeitel | set | recipients:
+ SebastianSpeitel |
2021-04-28 09:34:28 | SebastianSpeitel | set | messageid: <1619602468.72.0.276909030716.issue43965@roundup.psfhosted.org> |
2021-04-28 09:34:28 | SebastianSpeitel | link | issue43965 messages |
2021-04-28 09:34:28 | SebastianSpeitel | create | |
|