Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/howto/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ to use the standard :func:`repr`.

.. note::

Adding :deco:`~dataclasses.dataclass` decorator to :class:`Enum`
Adding :deco:`dataclass <dataclasses.dataclass>` decorator to :class:`Enum`
and its subclasses is not supported. It will not raise any errors,
but it will produce very strange results at runtime, such as members
being equal to each other::
Expand Down
3 changes: 2 additions & 1 deletion Doc/howto/sorting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ Odds and Ends
:meth:`~object.__lt__` is not implemented (see :func:`object.__lt__`
for details on the mechanics). To avoid surprises, :pep:`8`
recommends that all six comparison methods be implemented.
The :deco:`~functools.total_ordering` decorator is provided to make that
The :deco:`total_ordering <functools.total_ordering>` decorator is provided
to make that
task easier.

* Key functions need not depend directly on the objects being sorted. A key
Expand Down
3 changes: 2 additions & 1 deletion Doc/library/contextlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ Functions and classes provided:

.. decorator:: asynccontextmanager

Similar to :deco:`~contextlib.contextmanager`, but creates an
Similar to :deco:`contextmanager <contextlib.contextmanager>`, but creates
an
:ref:`asynchronous context manager <async-context-managers>`.

This function is a :term:`decorator` that can be used to define a factory
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Module contents
:class:`StrEnum` defaults to the lower-cased version of the member name,
while other Enums default to 1 and increase from there.

:deco:`~enum.property`
:deco:`property <enum.property>`

Allows :class:`Enum` members to have attributes without conflicting with
member names. The ``value`` and ``name`` attributes are implemented this
Expand Down
3 changes: 2 additions & 1 deletion Doc/library/functools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,8 @@ The :mod:`!functools` module defines the following functions:
return not arg

The same pattern can be used for other similar decorators:
:deco:`staticmethod`, :deco:`~abc.abstractmethod`, and others.
:deco:`staticmethod`, :deco:`abstractmethod <abc.abstractmethod>`, and
others.

.. versionadded:: 3.8

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/warnings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Available Functions
The deprecation message passed to the decorator is saved in the
``__deprecated__`` attribute on the decorated object.
If applied to an overload, the decorator
must be after the :deco:`~typing.overload` decorator
must be after the :deco:`overload <typing.overload>` decorator
for the attribute to exist on the overload as returned by
:func:`typing.get_overloads`.

Expand Down
2 changes: 1 addition & 1 deletion Doc/reference/expressions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ some consistency rules, if possible:

The last two expressions apply to totally ordered collections (e.g. to
sequences, but not to sets or mappings). See also the
:deco:`~functools.total_ordering` decorator.
:deco:`total_ordering <functools.total_ordering>` decorator.

* The :func:`hash` result should be consistent with equality.
Objects that are equal should either have the same hash value,
Expand Down
3 changes: 2 additions & 1 deletion Doc/whatsnew/2.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ The contextlib module
The new :mod:`contextlib` module provides some functions and a decorator that
are useful for writing objects for use with the ':keyword:`with`' statement.

The decorator is called :deco:`~contextlib.contextmanager`, and lets you write a single
The decorator is called :deco:`contextmanager <contextlib.contextmanager>`, and
lets you write a single
generator function instead of defining a new class. The generator should yield
exactly one value. The code up to the :keyword:`yield` will be executed as the
:meth:`~object.__enter__` method, and the value yielded will be the method's return
Expand Down
11 changes: 7 additions & 4 deletions Doc/whatsnew/2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ The contextlib module
The :mod:`contextlib` module provides some functions and a decorator that
are useful when writing objects for use with the ':keyword:`with`' statement.

The decorator is called :deco:`~contextlib.contextmanager`, and lets you write
The decorator is called :deco:`contextmanager <contextlib.contextmanager>`, and
lets you write
a single generator function instead of defining a new class. The generator
should yield exactly one value. The code up to the :keyword:`yield` will be
executed as the :meth:`~object.__enter__` method, and the value yielded will
Expand Down Expand Up @@ -1274,7 +1275,8 @@ of :meth:`!draw_doubled`, though they can do so. An implementation
of :meth:`!draw` is necessary, though; the ABC can't provide
a useful generic implementation.

You can apply the :deco:`~abc.abstractmethod` decorator to methods such as
You can apply the :deco:`abstractmethod <abc.abstractmethod>` decorator to
methods such as
:meth:`!draw` that must be implemented; Python will then raise an
exception for classes that don't define the method.
Note that the exception is only raised when you actually
Expand Down Expand Up @@ -1558,8 +1560,9 @@ Some smaller changes made to the core Python language are:

.. Revision 57619

* Properties now have three decorators, :deco:`~property.getter`,
:deco:`~property.setter` and :deco:`~property.deleter`, that are
* Properties now have three decorators, :deco:`getter <property.getter>`,
:deco:`setter <property.setter>` and :deco:`deleter <property.deleter>`, that
are
decorators providing useful shortcuts
for adding a getter, setter or deleter function to an existing
property. You would use them like this::
Expand Down
3 changes: 2 additions & 1 deletion Doc/whatsnew/2.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,8 @@ changes, or look through the Subversion logs for all the details.
uploads thanks to an added *rest* parameter (patch by Pablo Mouzo;
:issue:`6845`.)

* New class decorator: :deco:`~functools.total_ordering` in the :mod:`functools`
* New class decorator: :deco:`total_ordering <functools.total_ordering>` in the
:mod:`functools`
module takes a class that defines an :meth:`~object.__eq__` method and one of
:meth:`~object.__lt__`, :meth:`~object.__le__`, :meth:`~object.__gt__`, or :meth:`~object.__ge__`,
and generates the missing comparison methods. Since the
Expand Down
3 changes: 2 additions & 1 deletion Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,8 @@ is a :class:`typing.TypedDict`.

Subclasses of ``typing.Protocol`` which only have data variables declared
will now raise a ``TypeError`` when checked with ``isinstance`` unless they
are decorated with :deco:`~typing.runtime_checkable`. Previously, these checks
are decorated with :deco:`runtime_checkable <typing.runtime_checkable>`.
Previously, these checks
passed silently. Users should decorate their
subclasses with the :deco:`!runtime_checkable` decorator
if they want runtime protocols.
Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ Kumar Srinivasan and Graham Bleaney.)
PEP 681: Data class transforms
------------------------------

:deco:`~typing.dataclass_transform` may be used to
:deco:`dataclass_transform <typing.dataclass_transform>` may be used to
decorate a class, metaclass, or a function that is itself a decorator.
The presence of ``@dataclass_transform()`` tells a static type checker that the
decorated object performs runtime "magic" that transforms a class,
Expand Down Expand Up @@ -686,7 +686,7 @@ enum
* Added the :func:`~enum.member` and :func:`~enum.nonmember` decorators,
to ensure the decorated object is/is not converted to an enum member.

* Added the :deco:`~enum.property` decorator,
* Added the :deco:`property <enum.property>` decorator,
which works like :deco:`property` except for enums.
Use this instead of :func:`types.DynamicClassAttribute`.

Expand Down
3 changes: 2 additions & 1 deletion Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,8 @@ Changes in the Python API
around process-global resources, which are best managed from the main interpreter.
(Contributed by Donghee Na in :gh:`99127`.)

* The undocumented locking behavior of :deco:`~functools.cached_property`
* The undocumented locking behavior of
:deco:`cached_property <functools.cached_property>`
is removed, because it locked across all instances of the class, leading to high
lock contention. This means that a cached property getter function could now run
more than once for a single instance, if two threads race. For most simple
Expand Down
17 changes: 11 additions & 6 deletions Doc/whatsnew/3.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,8 @@ functools
methods to fill in the remaining methods.

For example, supplying *__eq__* and *__lt__* will enable
:deco:`~functools.total_ordering` to fill-in *__le__*, *__gt__* and *__ge__*::
:deco:`total_ordering <functools.total_ordering>` to fill-in *__le__*,
*__gt__* and *__ge__*::

@total_ordering
class Student:
Expand Down Expand Up @@ -1097,8 +1098,9 @@ logarithm of the gamma function:
abc
---

The :mod:`abc` module now supports :deco:`~abc.abstractclassmethod` and
:deco:`~abc.abstractstaticmethod`.
The :mod:`abc` module now supports
:deco:`abstractclassmethod <abc.abstractclassmethod>` and
:deco:`abstractstaticmethod <abc.abstractstaticmethod>`.

These tools make it possible to define an :term:`abstract base class` that
requires a particular :deco:`classmethod` or :deco:`staticmethod` to be
Expand Down Expand Up @@ -1155,7 +1157,8 @@ self-reference by displaying "..." in the recursive part of the representation
string.

To help write such :meth:`~object.__repr__` methods, the :mod:`reprlib` module has a new
decorator, :deco:`~reprlib.recursive_repr`, for detecting recursive calls to
decorator, :deco:`recursive_repr <reprlib.recursive_repr>`, for detecting
recursive calls to
:meth:`!__repr__` and substituting a placeholder string instead::

>>> class MyList(list):
Expand Down Expand Up @@ -1241,7 +1244,8 @@ There is a new and slightly mind-blowing tool
:term:`context manager` that does double duty as a function decorator.

As a convenience, this new functionality is used by
:deco:`~contextlib.contextmanager` so that no extra effort is needed to support
:deco:`contextmanager <contextlib.contextmanager>` so that no extra effort is
needed to support
both roles.

The basic idea is that both context managers and function decorators can be used
Expand All @@ -1253,7 +1257,8 @@ write a pre-action or post-action wrapper that can be used in either role.
For example, it is sometimes useful to wrap functions or groups of statements
with a logger that can track the time of entry and time of exit. Rather than
writing both a function decorator and a context manager for the task, the
:deco:`~contextlib.contextmanager` provides both capabilities in a single
:deco:`contextmanager <contextlib.contextmanager>` provides both capabilities
in a single
definition::

from contextlib import contextmanager
Expand Down
6 changes: 4 additions & 2 deletions Doc/whatsnew/3.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,8 @@ to behave like normal instance methods when included in a class definition.

.. _whatsnew-singledispatch:

The new :deco:`~functools.singledispatch` decorator brings support for
The new :deco:`singledispatch <functools.singledispatch>` decorator brings
support for
single-dispatch generic functions to the Python standard library. Where
object oriented programming focuses on grouping multiple operations on a
common set of data into a class, a generic function focuses on grouping
Expand All @@ -870,7 +871,8 @@ multiple implementations of an operation that allows it to work with
:pep:`443` -- Single-dispatch generic functions
PEP written and implemented by Łukasz Langa.

:deco:`~functools.total_ordering` now supports a return value of
:deco:`total_ordering <functools.total_ordering>` now supports a return value
of
:data:`NotImplemented` from the underlying comparison function. (Contributed
by Katie Miller in :issue:`10042`.)

Expand Down
3 changes: 2 additions & 1 deletion Doc/whatsnew/3.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,8 @@ functools

.. _whatsnew-lrucache:

Most of the :deco:`~functools.lru_cache` machinery is now implemented in C, making
Most of the :deco:`lru_cache <functools.lru_cache>` machinery is now
implemented in C, making
it significantly faster. (Contributed by Matt Joiner, Alexey Kachayev, and
Serhiy Storchaka in :issue:`14373`.)

Expand Down
5 changes: 3 additions & 2 deletions Doc/whatsnew/3.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,8 @@ decimal operations to work with the correct context in asynchronous code.
dataclasses
-----------

The new :deco:`~dataclasses.dataclass` decorator provides a way to declare
The new :deco:`dataclass <dataclasses.dataclass>` decorator provides a way to
declare
*data classes*. A data class describes its attributes using class variable
annotations. Its constructor and other magic methods, such as
:meth:`~object.__repr__`, :meth:`~object.__eq__`, and
Expand Down Expand Up @@ -830,7 +831,7 @@ The new :func:`~contextlib.nullcontext` is a simpler and faster no-op
context manager than :class:`~contextlib.ExitStack`.
(Contributed by Jesse-Bakker in :issue:`10049`.)

The new :deco:`~contextlib.asynccontextmanager`,
The new :deco:`asynccontextmanager <contextlib.asynccontextmanager>`,
:class:`~contextlib.AbstractAsyncContextManager`, and
:class:`~contextlib.AsyncExitStack` have been added to
complement their synchronous counterparts. (Contributed
Expand Down
Loading