Skip to content

Commit b21dd36

Browse files
[3.11] gh-88531 Fix dataclass __post_init__/__init__ interplay documentation (gh-107404) (#114163)
* Simplify __post_init__ example usage. It applies to all base classes, not just dataclasses. (cherry picked from commit 05008c2) Co-authored-by: Steffen Zeile <[email protected]>
1 parent 9351b5d commit b21dd36

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Doc/library/dataclasses.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,10 +529,10 @@ class :meth:`~object.__init__` methods. If the base class has an :meth:`~object.
529529
that has to be called, it is common to call this method in a
530530
:meth:`!__post_init__` method::
531531

532-
@dataclass
533532
class Rectangle:
534-
height: float
535-
width: float
533+
def __init__(self, height, width):
534+
self.height = height
535+
self.width = width
536536

537537
@dataclass
538538
class Square(Rectangle):

0 commit comments

Comments
 (0)