Skip to content

Commit f52151b

Browse files
authored
Remove discussion of alternate form (#2386)
1 parent dfdf510 commit f52151b

File tree

1 file changed

+4
-33
lines changed

1 file changed

+4
-33
lines changed

pep-0681.rst

+4-33
Original file line numberDiff line numberDiff line change
@@ -549,36 +549,6 @@ decorated with ``dataclass_transform`` is in use.
549549
`ignored by dataclass mechanisms <#class-var_>`_.
550550

551551

552-
Alternate form
553-
--------------
554-
555-
To avoid delaying adoption of this proposal until after
556-
``dataclass_transform`` has been added to the ``typing`` module, type
557-
checkers may support the alternative form ``__dataclass_transform__``.
558-
This form can be defined locally without any reliance on the
559-
``typing`` or ``typing_extensions`` modules, and allows immediate
560-
adoption of this specification by library authors. Type checkers that
561-
have not yet adopted this specification will retain their current
562-
behavior.
563-
564-
To use this alternate form, library authors should include the
565-
following declaration within their type stubs or source files:
566-
567-
.. code-block:: python
568-
569-
_T = TypeVar("_T")
570-
571-
def __dataclass_transform__(
572-
*,
573-
eq_default: bool = True,
574-
order_default: bool = False,
575-
kw_only_default: bool = False,
576-
field_descriptors: tuple[type | Callable[..., Any], ...] = (),
577-
) -> Callable[[_T], _T]:
578-
# If used within a stub file, the following implementation can
579-
# be replaced with "...".
580-
return lambda a: a
581-
582552
Undefined behavior
583553
------------------
584554

@@ -590,13 +560,14 @@ behavior is undefined. Library authors should avoid these scenarios.
590560
Reference Implementation
591561
========================
592562

593-
The `Pyright <#pyright_>`_ type checker supports the
594-
``__dataclass_transform__`` `alternate form`_. Pyright's
563+
`Pyright <#pyright_>`_ contains the reference implementation of type
564+
checker support for ``dataclass_transform``. Pyright's
595565
``dataClasses.ts`` `source file <#pyright-impl_>`_ would be a good
596566
starting point for understanding the implementation.
597567

598568
The `attrs <#attrs-usage_>`_ and `pydantic <#pydantic-usage_>`_
599-
libraries are using the ``__dataclass_transform__`` `alternate form`_.
569+
libraries are using ``dataclass_transform`` and serve as real-world
570+
examples of its usage.
600571

601572

602573
Rejected Ideas

0 commit comments

Comments
 (0)