This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author da2ce7
Recipients MicaelJarniac, andrei.avk, da2ce7, docs@python, eric.smith
Date 2021-10-31.17:30:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635701404.42.0.468242400145.issue44365@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-10-31 17:30:04da2ce7setrecipients: + da2ce7, eric.smith, docs@python, andrei.avk, MicaelJarniac
2021-10-31 17:30:04da2ce7setmessageid: <1635701404.42.0.468242400145.issue44365@roundup.psfhosted.org>
2021-10-31 17:30:04da2ce7linkissue44365 messages
2021-10-31 17:30:04da2ce7create