Sebastian Speitel added the comment:
Or maybe a cls argument which defaults to obj.__class__?
--
___
Python tracker
<https://bugs.python.org/issue43965>
___
___
Sebastian Speitel 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
New submission from Sebastian Speitel :
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,