gh-88531 Fix dataclass __post_init__/__init__ interplay documentation (gh-107404)

* Simplify __post_init__ example usage. It applies to all base classes, not just dataclasses.
This commit is contained in:
Steffen Zeile 2024-01-17 02:17:34 +01:00 committed by GitHub
parent 60ca37fdee
commit 05008c27b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -536,10 +536,10 @@ class :meth:`~object.__init__` methods. If the base class has an :meth:`~object.
that has to be called, it is common to call this method in a
:meth:`__post_init__` method::
@dataclass
class Rectangle:
height: float
width: float
def __init__(self, height, width):
self.height = height
self.width = width
@dataclass
class Square(Rectangle):