@@ -317,7 +317,7 @@ Module contents
317
317
:func: `!field `, then the class attribute for this field will be
318
318
replaced by the specified *default * value. If *default * is not
319
319
provided, then the class attribute will be deleted. The intent is
320
- that after the :func: ` @ dataclass <dataclass> ` decorator runs, the class
320
+ that after the :deco: ` dataclass ` decorator runs, the class
321
321
attributes will all contain the default values for the fields, just
322
322
as if the default value itself were specified. For example,
323
323
after::
@@ -427,20 +427,20 @@ Module contents
427
427
:data: `typing.Any ` is used for ``type ``. The values of *init *,
428
428
*repr *, *eq *, *order *, *unsafe_hash *, *frozen *,
429
429
*match_args *, *kw_only *, *slots *, and *weakref_slot * have
430
- the same meaning as they do in :func: ` @ dataclass <dataclass> `.
430
+ the same meaning as they do in :deco: ` dataclass `.
431
431
432
432
If *module * is defined, the :attr: `!__module__ ` attribute
433
433
of the dataclass is set to that value.
434
434
By default, it is set to the module name of the caller.
435
435
436
436
The *decorator * parameter is a callable that will be used to create the dataclass.
437
437
It should take the class object as a first argument and the same keyword arguments
438
- as :func: ` @ dataclass <dataclass> `. By default, the :func: ` @ dataclass <dataclass> `
438
+ as :deco: ` dataclass `. By default, the :deco: ` dataclass `
439
439
function is used.
440
440
441
441
This function is not strictly required, because any Python
442
442
mechanism for creating a new class with :attr: `~object.__annotations__ ` can
443
- then apply the :func: ` @ dataclass <dataclass> ` function to convert that class to
443
+ then apply the :deco: ` dataclass ` function to convert that class to
444
444
a dataclass. This function is provided as a convenience. For
445
445
example::
446
446
@@ -569,7 +569,7 @@ Post-init processing
569
569
def __post_init__(self):
570
570
self.c = self.a + self.b
571
571
572
- The :meth: `~object.__init__ ` method generated by :func: ` @ dataclass <dataclass> ` does not call base
572
+ The :meth: `~object.__init__ ` method generated by :deco: ` dataclass ` does not call base
573
573
class :meth: `!__init__ ` methods. If the base class has an :meth: `!__init__ ` method
574
574
that has to be called, it is common to call this method in a
575
575
:meth: `__post_init__ ` method::
@@ -599,7 +599,7 @@ parameters to :meth:`!__post_init__`. Also see the warning about how
599
599
Class variables
600
600
---------------
601
601
602
- One of the few places where :func: ` @ dataclass <dataclass> ` actually inspects the type
602
+ One of the few places where :deco: ` dataclass ` actually inspects the type
603
603
of a field is to determine if a field is a class variable as defined
604
604
in :pep: `526 `. It does this by checking if the type of the field is
605
605
:data: `typing.ClassVar `. If a field is a ``ClassVar ``, it is excluded
@@ -612,7 +612,7 @@ module-level :func:`fields` function.
612
612
Init-only variables
613
613
-------------------
614
614
615
- Another place where :func: ` @ dataclass <dataclass> ` inspects a type annotation is to
615
+ Another place where :deco: ` dataclass ` inspects a type annotation is to
616
616
determine if a field is an init-only variable. It does this by seeing
617
617
if the type of a field is of type :class: `InitVar `. If a field
618
618
is an :class: `InitVar `, it is considered a pseudo-field called an init-only
@@ -646,7 +646,7 @@ Frozen instances
646
646
----------------
647
647
648
648
It is not possible to create truly immutable Python objects. However,
649
- by passing ``frozen=True `` to the :func: ` @ dataclass <dataclass> ` decorator you can
649
+ by passing ``frozen=True `` to the :deco: ` dataclass ` decorator you can
650
650
emulate immutability. In that case, dataclasses will add
651
651
:meth: `~object.__setattr__ ` and :meth: `~object.__delattr__ ` methods to the class. These
652
652
methods will raise a :exc: `FrozenInstanceError ` when invoked.
@@ -662,7 +662,7 @@ must use :meth:`!object.__setattr__`.
662
662
Inheritance
663
663
-----------
664
664
665
- When the dataclass is being created by the :func: ` @ dataclass <dataclass> ` decorator,
665
+ When the dataclass is being created by the :deco: ` dataclass ` decorator,
666
666
it looks through all of the class's base classes in reverse MRO (that
667
667
is, starting at :class: `object `) and, for each dataclass that it finds,
668
668
adds the fields from that base class to an ordered mapping of fields.
@@ -786,7 +786,7 @@ for :attr:`!x` when creating a class instance will share the same copy
786
786
of :attr: `!x `. Because dataclasses just use normal Python class
787
787
creation they also share this behavior. There is no general way
788
788
for Data Classes to detect this condition. Instead, the
789
- :func: ` @ dataclass <dataclass> ` decorator will raise a :exc: `ValueError ` if it
789
+ :deco: ` dataclass ` decorator will raise a :exc: `ValueError ` if it
790
790
detects an unhashable default parameter. The assumption is that if
791
791
a value is unhashable, it is mutable. This is a partial solution,
792
792
but it does protect against many common errors.
@@ -820,7 +820,7 @@ default value have the following special behaviors:
820
820
:meth: `~object.__get__ ` or :meth: `!__set__ ` method is called rather than returning or
821
821
overwriting the descriptor object.
822
822
823
- * To determine whether a field contains a default value, :func: ` @ dataclass <dataclass> `
823
+ * To determine whether a field contains a default value, :deco: ` dataclass `
824
824
will call the descriptor's :meth: `!__get__ ` method using its class access
825
825
form: ``descriptor.__get__(obj=None, type=cls) ``. If the
826
826
descriptor returns a value in this case, it will be used as the
0 commit comments