[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 05008c27b7)

Co-authored-by: Steffen Zeile <48187781+Kaniee@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-01-17 02:33:09 +01:00 committed by GitHub
parent 9351b5ddf1
commit b21dd36495
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -529,10 +529,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):