Skip to content

Commit 05008c2

Browse files
authored
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.
1 parent 60ca37f commit 05008c2

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

539-
@dataclass
540539
class Rectangle:
541-
height: float
542-
width: float
540+
def __init__(self, height, width):
541+
self.height = height
542+
self.width = width
543543

544544
@dataclass
545545
class Square(Rectangle):

0 commit comments

Comments
 (0)