PEP 681: Clarifications about classes decorated with `dataclass_transform` (#2815)

This commit is contained in:
Erik De Bonte 2022-10-05 09:43:49 -07:00 committed by GitHub
parent 290853700e
commit b4bed87dd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -109,8 +109,10 @@ than one, of the overloads. When applied to an overload, the
function.
If ``dataclass_transform`` is applied to a class, dataclass-like
semantics will be assumed for any class that derives from the
decorated class or uses the decorated class as a metaclass.
semantics will be assumed for any class that directly or indirectly
derives from the decorated class or uses the decorated class as a
metaclass. Attributes on the decorated class and its base classes
are not considered to be fields.
Examples of each approach are shown in the following sections. Each
example creates a ``CustomerModel`` class with dataclass-like semantics.
@ -568,8 +570,11 @@ This includes, but is not limited to, the following semantics:
keyword-only parameters are used for ``__init__``, so the rule is
not enforced if ``kw_only`` semantics are in effect.
* As with dataclass, method synthesis is skipped if it would
* As with ``dataclass``, method synthesis is skipped if it would
overwrite a method that is explicitly declared within the class.
Method declarations on base classes do not cause method synthesis to
be skipped.
For example, if a class declares an ``__init__`` method explicitly,
an ``__init__`` method will not be synthesized for that class.