da2ce7 <[email protected]> added the comment:
Amazingly, the original example needs a very small change to make it work as
expected:
@dataclass
class Rectangle:
height: float
width: float
@dataclass
class Square(Rectangle):
side: float
height: float = field(init=False)
width: float = field(init=False)
def __post_init__(self) -> None:
super().__init__(self.side, self.side)
I discover this now, after playing around for a while.
Attached is the simplified version of my expanded example testcase.
----------
Added file: https://bugs.python.org/file50416/dataclass_inheritance_v3_test.py
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44365>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com