[issue43965] dataclasses.replace breaks when __init__ is overrriden in subclass

Sebastian Speitel report at bugs.python.org
Wed Apr 28 05:56:14 EDT 2021


Sebastian Speitel <sebastian.speitel at outlook.de> added the comment:

One solution I thought of was to return not an object of the same instance, but one of the same dataclass, which would allow the implementation to traverse the class hierachy of the object and create an instance of the first dataclass-class (or class with same __init__ signature) it finds with the changes applied.

This would at least allow using replace instead of it just failing in more cases.

But according to the PEP
> Creates a new object of the same type of [the] instance
the returned object has to have the same type.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43965>
_______________________________________


More information about the Python-bugs-list mailing list