@@ -549,36 +549,6 @@ decorated with ``dataclass_transform`` is in use.
549
549
`ignored by dataclass mechanisms <#class-var _>`_.
550
550
551
551
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
-
582
552
Undefined behavior
583
553
------------------
584
554
@@ -590,13 +560,14 @@ behavior is undefined. Library authors should avoid these scenarios.
590
560
Reference Implementation
591
561
========================
592
562
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
595
565
``dataClasses.ts `` `source file <#pyright-impl _>`_ would be a good
596
566
starting point for understanding the implementation.
597
567
598
568
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.
600
571
601
572
602
573
Rejected Ideas
0 commit comments