Skip to content

Commit 052d0aa

Browse files
committed
docs: fix over-linking in dataclasses.rst
1 parent 408e127 commit 052d0aa

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

Doc/library/dataclasses.rst

+27-27
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,26 @@ Module contents
4949
.. decorator:: dataclass(*, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)
5050

5151
This function is a :term:`decorator` that is used to add generated
52-
:term:`special method`\s to classes, as described below.
52+
:term:`special methods <special method>` to classes, as described below.
5353

54-
The :func:`dataclass` decorator examines the class to find
54+
The :func:`!dataclass` decorator examines the class to find
5555
``field``\s. A ``field`` is defined as a class variable that has a
5656
:term:`type annotation <variable annotation>`. With two
57-
exceptions described below, nothing in :func:`dataclass`
57+
exceptions described below, nothing in :func:`!dataclass`
5858
examines the type specified in the variable annotation.
5959

6060
The order of the fields in all of the generated methods is the
6161
order in which they appear in the class definition.
6262

63-
The :func:`dataclass` decorator will add various "dunder" methods to
63+
The :func:`!dataclass` decorator will add various "dunder" methods to
6464
the class, described below. If any of the added methods already
6565
exist in the class, the behavior depends on the parameter, as documented
6666
below. The decorator returns the same class that it is called on; no new
6767
class is created.
6868

69-
If :func:`dataclass` is used just as a simple decorator with no parameters,
69+
If :func:`!dataclass` is used just as a simple decorator with no parameters,
7070
it acts as if it has the default values documented in this
71-
signature. That is, these three uses of :func:`dataclass` are
71+
signature. That is, these three uses of :func:`!dataclass` are
7272
equivalent::
7373

7474
@dataclass
@@ -84,7 +84,7 @@ Module contents
8484
class C:
8585
...
8686

87-
The parameters to :func:`dataclass` are:
87+
The parameters to :func:`!dataclass` are:
8888

8989
- ``init``: If true (the default), a :meth:`~object.__init__` method will be
9090
generated.
@@ -129,17 +129,17 @@ Module contents
129129
:meth:`~object.__hash__` implies that instances of the class are immutable.
130130
Mutability is a complicated property that depends on the programmer's
131131
intent, the existence and behavior of :meth:`~object.__eq__`, and the values of
132-
the ``eq`` and ``frozen`` flags in the :func:`dataclass` decorator.
132+
the ``eq`` and ``frozen`` flags in the :func:`!dataclass` decorator.
133133

134-
By default, :func:`dataclass` will not implicitly add a :meth:`~object.__hash__`
134+
By default, :func:`!dataclass` will not implicitly add a :meth:`~object.__hash__`
135135
method unless it is safe to do so. Neither will it add or change an
136136
existing explicitly defined :meth:`~object.__hash__` method. Setting the class
137137
attribute ``__hash__ = None`` has a specific meaning to Python, as
138138
described in the :meth:`~object.__hash__` documentation.
139139

140140
If :meth:`~object.__hash__` is not explicitly defined, or if it is set to ``None``,
141-
then :func:`dataclass` *may* add an implicit :meth:`~object.__hash__` method.
142-
Although not recommended, you can force :func:`dataclass` to create a
141+
then :func:`!dataclass` *may* add an implicit :meth:`~object.__hash__` method.
142+
Although not recommended, you can force :func:`!dataclass` to create a
143143
:meth:`~object.__hash__` method with ``unsafe_hash=True``. This might be the case
144144
if your class is logically immutable but can still be mutated.
145145
This is a specialized use case and should be considered carefully.
@@ -149,7 +149,7 @@ Module contents
149149
method in your dataclass and set ``unsafe_hash=True``; this will result
150150
in a :exc:`TypeError`.
151151

152-
If ``eq`` and ``frozen`` are both true, by default :func:`dataclass` will
152+
If ``eq`` and ``frozen`` are both true, by default :func:`!dataclass` will
153153
generate a :meth:`~object.__hash__` method for you. If ``eq`` is true and
154154
``frozen`` is false, :meth:`~object.__hash__` will be set to ``None``, marking it
155155
unhashable (which it is, since it is mutable). If ``eq`` is false,
@@ -229,7 +229,7 @@ Module contents
229229
required. There are, however, some dataclass features that
230230
require additional per-field information. To satisfy this need for
231231
additional information, you can replace the default field value
232-
with a call to the provided :func:`field` function. For example::
232+
with a call to the provided :func:`!field` function. For example::
233233

234234
@dataclass
235235
class C:
@@ -243,10 +243,10 @@ Module contents
243243
used because ``None`` is a valid value for some parameters with
244244
a distinct meaning. No code should directly use the :const:`MISSING` value.
245245

246-
The parameters to :func:`field` are:
246+
The parameters to :func:`!field` are:
247247

248248
- ``default``: If provided, this will be the default value for this
249-
field. This is needed because the :meth:`field` call itself
249+
field. This is needed because the :func:`!field` call itself
250250
replaces the normal position of the default value.
251251

252252
- ``default_factory``: If provided, it must be a zero-argument
@@ -293,7 +293,7 @@ Module contents
293293
.. versionadded:: 3.10
294294

295295
If the default value of a field is specified by a call to
296-
:func:`field()`, then the class attribute for this field will be
296+
:func:`!field`, then the class attribute for this field will be
297297
replaced by the specified ``default`` value. If no ``default`` is
298298
provided, then the class attribute will be deleted. The intent is
299299
that after the :func:`dataclass` decorator runs, the class
@@ -343,7 +343,7 @@ Module contents
343343
lists, and tuples are recursed into. Other objects are copied with
344344
:func:`copy.deepcopy`.
345345

346-
Example of using :func:`asdict` on nested dataclasses::
346+
Example of using :func:`!asdict` on nested dataclasses::
347347

348348
@dataclass
349349
class Point:
@@ -364,7 +364,7 @@ Module contents
364364

365365
dict((field.name, getattr(obj, field.name)) for field in fields(obj))
366366

367-
:func:`asdict` raises :exc:`TypeError` if ``obj`` is not a dataclass
367+
:func:`!asdict` raises :exc:`TypeError` if ``obj`` is not a dataclass
368368
instance.
369369

370370
.. function:: astuple(obj, *, tuple_factory=tuple)
@@ -384,7 +384,7 @@ Module contents
384384

385385
tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))
386386

387-
:func:`astuple` raises :exc:`TypeError` if ``obj`` is not a dataclass
387+
:func:`!astuple` raises :exc:`TypeError` if ``obj`` is not a dataclass
388388
instance.
389389

390390
.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False, module=None)
@@ -438,15 +438,15 @@ Module contents
438438
:meth:`__post_init__`, if present, is also called.
439439

440440
Init-only variables without default values, if any exist, must be
441-
specified on the call to :func:`replace` so that they can be passed to
441+
specified on the call to :func:`!replace` so that they can be passed to
442442
:meth:`~object.__init__` and :meth:`__post_init__`.
443443

444444
It is an error for ``changes`` to contain any fields that are
445445
defined as having ``init=False``. A :exc:`ValueError` will be raised
446446
in this case.
447447

448448
Be forewarned about how ``init=False`` fields work during a call to
449-
:func:`replace`. They are not copied from the source object, but
449+
:func:`!replace`. They are not copied from the source object, but
450450
rather are initialized in :meth:`__post_init__`, if they're
451451
initialized at all. It is expected that ``init=False`` fields will
452452
be rarely and judiciously used. If they are used, it might be wise
@@ -475,11 +475,11 @@ Module contents
475475
.. data:: KW_ONLY
476476

477477
A sentinel value used as a type annotation. Any fields after a
478-
pseudo-field with the type of :const:`KW_ONLY` are marked as
478+
pseudo-field with the type of :const:`!KW_ONLY` are marked as
479479
keyword-only fields. Note that a pseudo-field of type
480-
:const:`KW_ONLY` is otherwise completely ignored. This includes the
480+
:const:`!KW_ONLY` is otherwise completely ignored. This includes the
481481
name of such a field. By convention, a name of ``_`` is used for a
482-
:const:`KW_ONLY` field. Keyword-only fields signify
482+
:const:`!KW_ONLY` field. Keyword-only fields signify
483483
:meth:`~object.__init__` parameters that must be specified as keywords when
484484
the class is instantiated.
485485

@@ -495,7 +495,7 @@ Module contents
495495
p = Point(0, y=1.5, z=2.0)
496496

497497
In a single dataclass, it is an error to specify more than one
498-
field whose type is :const:`KW_ONLY`.
498+
field whose type is :const:`!KW_ONLY`.
499499

500500
.. versionadded:: 3.10
501501

@@ -515,9 +515,9 @@ Post-init processing
515515
When defined on the class, it will be called by the generated
516516
:meth:`~object.__init__`, normally as ``self.__post_init__()``.
517517
However, if any ``InitVar`` fields are defined, they will also be
518-
passed to :meth:`__post_init__` in the order they were defined in the
518+
passed to :meth:`!__post_init__` in the order they were defined in the
519519
class. If no :meth:`~object.__init__` method is generated, then
520-
:meth:`__post_init__` will not automatically be called.
520+
:meth:`!__post_init__` will not automatically be called.
521521

522522
Among other uses, this allows for initializing field values that
523523
depend on one or more other fields. For example::

0 commit comments

Comments
 (0)