Skip to content

Commit 12c6424

Browse files
[3.12] gh-88531 Fix dataclass __post_init__/__init__ interplay documentation (gh-107404) (#114162)
* 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 b201a6a commit 12c6424

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
@@ -534,10 +534,10 @@ class :meth:`~object.__init__` methods. If the base class has an :meth:`~object.
534534
that has to be called, it is common to call this method in a
535535
:meth:`__post_init__` method::
536536

537-
@dataclass
538537
class Rectangle:
539-
height: float
540-
width: float
538+
def __init__(self, height, width):
539+
self.height = height
540+
self.width = width
541541

542542
@dataclass
543543
class Square(Rectangle):

0 commit comments

Comments
 (0)