New submission from Sebastian Speitel <sebastian.spei...@outlook.de>:
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. ---------- components: Library (Lib) messages: 392174 nosy: SebastianSpeitel priority: normal severity: normal status: open title: dataclasses.replace breaks when __init__ is overrriden in subclass type: behavior versions: Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43965> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com