https://github.com/python/cpython/commit/dbe44f150cd161bd327ed662e527a4c93829fb3e
commit: dbe44f150cd161bd327ed662e527a4c93829fb3e
branch: main
author: Erlend E. Aasland <[email protected]>
committer: erlend-aasland <[email protected]>
date: 2024-02-29T20:46:12Z
summary:
Docs: mark up NotImplemented using the :data: role throughout the docs (#116135)
files:
M Doc/library/abc.rst
M Doc/library/constants.rst
M Doc/library/exceptions.rst
M Doc/library/importlib.rst
M Doc/library/numbers.rst
M Doc/library/pickle.rst
M Doc/library/stdtypes.rst
M Doc/library/unittest.mock.rst
M Doc/reference/datamodel.rst
M Doc/reference/expressions.rst
M Doc/whatsnew/2.7.rst
M Doc/whatsnew/3.10.rst
M Doc/whatsnew/3.4.rst
M Doc/whatsnew/3.9.rst
M Misc/NEWS.d/3.10.0a6.rst
M Misc/NEWS.d/3.11.0a1.rst
diff --git a/Doc/library/abc.rst b/Doc/library/abc.rst
index c073ea955abaa4..10e2cba50e49b0 100644
--- a/Doc/library/abc.rst
+++ b/Doc/library/abc.rst
@@ -101,11 +101,11 @@ a helper class :class:`ABC` to alternatively define ABCs
through inheritance:
subclass of the ABC. (This class method is called from the
:meth:`~class.__subclasscheck__` method of the ABC.)
- This method should return ``True``, ``False`` or ``NotImplemented``. If
+ This method should return ``True``, ``False`` or :data:`NotImplemented`.
If
it returns ``True``, the *subclass* is considered a subclass of this ABC.
If it returns ``False``, the *subclass* is not considered a subclass of
this ABC, even if it would normally be one. If it returns
- ``NotImplemented``, the subclass check is continued with the usual
+ :data:`!NotImplemented`, the subclass check is continued with the usual
mechanism.
.. XXX explain the "usual mechanism"
diff --git a/Doc/library/constants.rst b/Doc/library/constants.rst
index 401dc9a320c5e0..93a7244f87de6b 100644
--- a/Doc/library/constants.rst
+++ b/Doc/library/constants.rst
@@ -33,27 +33,27 @@ A small number of constants live in the built-in namespace.
They are:
the other type; may be returned by the in-place binary special methods
(e.g. :meth:`~object.__imul__`, :meth:`~object.__iand__`, etc.) for the
same purpose.
It should not be evaluated in a boolean context.
- ``NotImplemented`` is the sole instance of the
:data:`types.NotImplementedType` type.
+ :data:`!NotImplemented` is the sole instance of the
:data:`types.NotImplementedType` type.
.. note::
- When a binary (or in-place) method returns ``NotImplemented`` the
+ When a binary (or in-place) method returns :data:`!NotImplemented` the
interpreter will try the reflected operation on the other type (or some
other fallback, depending on the operator). If all attempts return
- ``NotImplemented``, the interpreter will raise an appropriate exception.
- Incorrectly returning ``NotImplemented`` will result in a misleading
- error message or the ``NotImplemented`` value being returned to Python
code.
+ :data:`!NotImplemented`, the interpreter will raise an appropriate
exception.
+ Incorrectly returning :data:`!NotImplemented` will result in a misleading
+ error message or the :data:`!NotImplemented` value being returned to
Python code.
See :ref:`implementing-the-arithmetic-operations` for examples.
.. note::
- ``NotImplementedError`` and ``NotImplemented`` are not interchangeable,
+ ``NotImplementedError`` and :data:`!NotImplemented` are not
interchangeable,
even though they have similar names and purposes.
See :exc:`NotImplementedError` for details on when to use it.
.. versionchanged:: 3.9
- Evaluating ``NotImplemented`` in a boolean context is deprecated. While
+ Evaluating :data:`!NotImplemented` in a boolean context is deprecated.
While
it currently evaluates as true, it will emit a :exc:`DeprecationWarning`.
It will raise a :exc:`TypeError` in a future version of Python.
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 88417b40e4aa7f..7879fb015bddfa 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -335,9 +335,9 @@ The following exceptions are the exceptions that are
usually raised.
.. note::
- ``NotImplementedError`` and ``NotImplemented`` are not interchangeable,
+ ``NotImplementedError`` and :data:`NotImplemented` are not
interchangeable,
even though they have similar names and purposes. See
- :data:`NotImplemented` for details on when to use it.
+ :data:`!NotImplemented` for details on when to use it.
.. exception:: OSError([arg])
OSError(errno, strerror[, filename[, winerror[, filename2]]])
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 2402bc5cd3ee2c..d92bb2f8e5cf83 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -265,7 +265,7 @@ ABC hierarchy::
when invalidating the caches of all finders on :data:`sys.meta_path`.
.. versionchanged:: 3.4
- Returns ``None`` when called instead of ``NotImplemented``.
+ Returns ``None`` when called instead of :data:`NotImplemented`.
.. class:: PathEntryFinder
diff --git a/Doc/library/numbers.rst b/Doc/library/numbers.rst
index 17d1a275f04c9b..306bdd94aaca13 100644
--- a/Doc/library/numbers.rst
+++ b/Doc/library/numbers.rst
@@ -166,7 +166,7 @@ Complex``. I'll consider ``a + b``:
2. If ``A`` falls back to the boilerplate code, and it were to
return a value from :meth:`~object.__add__`, we'd miss the possibility
that ``B`` defines a more intelligent :meth:`~object.__radd__`, so the
- boilerplate should return :const:`NotImplemented` from
+ boilerplate should return :data:`NotImplemented` from
:meth:`!__add__`. (Or ``A`` may not implement :meth:`!__add__` at
all.)
3. Then ``B``'s :meth:`~object.__radd__` gets a chance. If it accepts
diff --git a/Doc/library/pickle.rst b/Doc/library/pickle.rst
index cb517681fa81b9..223c27237e4d34 100644
--- a/Doc/library/pickle.rst
+++ b/Doc/library/pickle.rst
@@ -377,7 +377,7 @@ The :mod:`pickle` module exports three classes,
:class:`Pickler`,
Special reducer that can be defined in :class:`Pickler` subclasses. This
method has priority over any reducer in the :attr:`dispatch_table`. It
should conform to the same interface as a :meth:`~object.__reduce__`
method, and
- can optionally return ``NotImplemented`` to fallback on
+ can optionally return :data:`NotImplemented` to fallback on
:attr:`dispatch_table`-registered reducers to pickle ``obj``.
For a detailed example, see :ref:`reducer_override`.
@@ -503,7 +503,7 @@ What can be pickled and unpickled?
The following types can be pickled:
* built-in constants (``None``, ``True``, ``False``, ``Ellipsis``, and
- ``NotImplemented``);
+ :data:`NotImplemented`);
* integers, floating-point numbers, complex numbers;
@@ -905,7 +905,7 @@ functions and classes.
For those cases, it is possible to subclass from the :class:`Pickler` class and
implement a :meth:`~Pickler.reducer_override` method. This method can return an
arbitrary reduction tuple (see :meth:`~object.__reduce__`). It can
alternatively return
-``NotImplemented`` to fallback to the traditional behavior.
+:data:`NotImplemented` to fallback to the traditional behavior.
If both the :attr:`~Pickler.dispatch_table` and
:meth:`~Pickler.reducer_override` are defined, then
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 1a4c12590c1018..c81626a194e640 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -5450,10 +5450,10 @@ The NotImplemented Object
This object is returned from comparisons and binary operations when they are
asked to operate on types they don't support. See :ref:`comparisons` for more
-information. There is exactly one ``NotImplemented`` object.
-``type(NotImplemented)()`` produces the singleton instance.
+information. There is exactly one :data:`NotImplemented` object.
+:code:`type(NotImplemented)()` produces the singleton instance.
-It is written as ``NotImplemented``.
+It is written as :code:`NotImplemented`.
.. _typesinternal:
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst
index b0a5d96c38d375..1f25a16f544da8 100644
--- a/Doc/library/unittest.mock.rst
+++ b/Doc/library/unittest.mock.rst
@@ -2143,10 +2143,10 @@ to change the default.
Methods and their defaults:
-* ``__lt__``: ``NotImplemented``
-* ``__gt__``: ``NotImplemented``
-* ``__le__``: ``NotImplemented``
-* ``__ge__``: ``NotImplemented``
+* ``__lt__``: :data:`NotImplemented`
+* ``__gt__``: :data:`!NotImplemented`
+* ``__le__``: :data:`!NotImplemented`
+* ``__ge__``: :data:`!NotImplemented`
* ``__int__``: ``1``
* ``__contains__``: ``False``
* ``__len__``: ``0``
diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst
index 6438abbba10e37..1aef2668e82cd1 100644
--- a/Doc/reference/datamodel.rst
+++ b/Doc/reference/datamodel.rst
@@ -159,7 +159,7 @@ NotImplemented
.. index:: pair: object; NotImplemented
This type has a single value. There is a single object with this value. This
-object is accessed through the built-in name ``NotImplemented``. Numeric
methods
+object is accessed through the built-in name :data:`NotImplemented`. Numeric
methods
and rich comparison methods should return this value if they do not implement
the
operation for the operands provided. (The interpreter will then try the
reflected operation, or some other fallback, depending on the operator.) It
@@ -170,7 +170,7 @@ See
for more details.
.. versionchanged:: 3.9
- Evaluating ``NotImplemented`` in a boolean context is deprecated. While
+ Evaluating :data:`NotImplemented` in a boolean context is deprecated. While
it currently evaluates as true, it will emit a :exc:`DeprecationWarning`.
It will raise a :exc:`TypeError` in a future version of Python.
@@ -1787,7 +1787,7 @@ Basic customization
``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls
``x.__ge__(y)``.
- A rich comparison method may return the singleton ``NotImplemented`` if it
does
+ A rich comparison method may return the singleton :data:`NotImplemented` if
it does
not implement the operation for a given pair of arguments. By convention,
``False`` and ``True`` are returned for a successful comparison. However,
these
methods can return any value, so if the comparison operator is used in a
Boolean
@@ -1795,10 +1795,10 @@ Basic customization
:func:`bool` on the value to determine if the result is true or false.
By default, ``object`` implements :meth:`__eq__` by using ``is``, returning
- ``NotImplemented`` in the case of a false comparison:
+ :data:`NotImplemented` in the case of a false comparison:
``True if x is y else NotImplemented``. For :meth:`__ne__`, by default it
delegates to :meth:`__eq__` and inverts the result unless it is
- ``NotImplemented``. There are no other implied relationships among the
+ :data:`!NotImplemented`. There are no other implied relationships among the
comparison operators or default implementations; for example, the truth of
``(x<y or x==y)`` does not imply ``x<=y``. To automatically generate
ordering
operations from a single root operation, see
:func:`functools.total_ordering`.
@@ -2828,7 +2828,7 @@ through the object's keys; for sequences, it should
iterate through the values.
Called to implement :func:`operator.length_hint`. Should return an estimated
length for the object (which may be greater or less than the actual length).
The length must be an integer ``>=`` 0. The return value may also be
- :const:`NotImplemented`, which is treated the same as if the
+ :data:`NotImplemented`, which is treated the same as if the
``__length_hint__`` method didn't exist at all. This method is purely an
optimization and is never required for correctness.
@@ -2980,7 +2980,7 @@ left undefined.
function is to be supported.
If one of those methods does not support the operation with the supplied
- arguments, it should return ``NotImplemented``.
+ arguments, it should return :data:`NotImplemented`.
.. method:: object.__radd__(self, other)
@@ -3010,7 +3010,7 @@ left undefined.
types. [#]_ For instance, to evaluate the expression ``x - y``, where *y* is
an instance of a class that has an :meth:`__rsub__` method,
``type(y).__rsub__(y, x)`` is called if ``type(x).__sub__(x, y)`` returns
- *NotImplemented*.
+ :data:`NotImplemented`.
.. index:: pair: built-in function; pow
@@ -3503,7 +3503,7 @@ An example of an asynchronous context manager class::
the behavior that ``None`` is not callable.
.. [#] "Does not support" here means that the class has no such method, or
- the method returns ``NotImplemented``. Do not set the method to
+ the method returns :data:`NotImplemented`. Do not set the method to
``None`` if you want to force fallback to the right operand's reflected
method—that will instead have the opposite effect of explicitly
*blocking* such fallback.
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 50e0f97a6534af..00b57effd3e1c0 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -1539,7 +1539,7 @@ built-in types.
``x == x`` are all false, while ``x != x`` is true. This behavior is
compliant with IEEE 754.
-* ``None`` and ``NotImplemented`` are singletons. :PEP:`8` advises that
+* ``None`` and :data:`NotImplemented` are singletons. :PEP:`8` advises that
comparisons for singletons should always be done with ``is`` or ``is not``,
never the equality operators.
diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst
index 2a42664c02852c..5c99fbc503ba65 100644
--- a/Doc/whatsnew/2.7.rst
+++ b/Doc/whatsnew/2.7.rst
@@ -1130,7 +1130,7 @@ changes, or look through the Subversion logs for all the
details.
(Added by Raymond Hettinger; :issue:`1818`.)
Finally, the :class:`~collections.abc.Mapping` abstract base class now
- returns :const:`NotImplemented` if a mapping is compared to
+ returns :data:`NotImplemented` if a mapping is compared to
another type that isn't a :class:`Mapping`.
(Fixed by Daniel Stutzbach; :issue:`8729`.)
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 9770b12c8af711..e35179a2d8e513 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -828,7 +828,7 @@ Other Language Changes
:meth:`~object.__index__` method).
(Contributed by Serhiy Storchaka in :issue:`37999`.)
-* If :func:`object.__ipow__` returns :const:`NotImplemented`, the operator will
+* If :func:`object.__ipow__` returns :data:`NotImplemented`, the operator will
correctly fall back to :func:`object.__pow__` and :func:`object.__rpow__` as
expected.
(Contributed by Alex Shkop in :issue:`38302`.)
diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst
index e07eda985d9bad..3dd400c3771ed2 100644
--- a/Doc/whatsnew/3.4.rst
+++ b/Doc/whatsnew/3.4.rst
@@ -872,7 +872,7 @@ multiple implementations of an operation that allows it to
work with
PEP written and implemented by Łukasz Langa.
:func:`~functools.total_ordering` now supports a return value of
-:const:`NotImplemented` from the underlying comparison function. (Contributed
+:data:`NotImplemented` from the underlying comparison function. (Contributed
by Katie Miller in :issue:`10042`.)
A pure-python version of the :func:`~functools.partial` function is now in the
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index b24c13813be220..49d926b0edcd0f 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -1126,7 +1126,7 @@ Changes in the Python API
``logging.getLogger(__name__)`` in some top-level module called
``'root.py'``.
(Contributed by Vinay Sajip in :issue:`37742`.)
-* Division handling of :class:`~pathlib.PurePath` now returns
``NotImplemented``
+* Division handling of :class:`~pathlib.PurePath` now returns
:data:`NotImplemented`
instead of raising a :exc:`TypeError` when passed something other than an
instance of ``str`` or :class:`~pathlib.PurePath`. This allows creating
compatible classes that don't inherit from those mentioned types.
diff --git a/Misc/NEWS.d/3.10.0a6.rst b/Misc/NEWS.d/3.10.0a6.rst
index c379b968c9885b..bad3528084897b 100644
--- a/Misc/NEWS.d/3.10.0a6.rst
+++ b/Misc/NEWS.d/3.10.0a6.rst
@@ -158,7 +158,7 @@ tests that are unrelated to :class:`ProcessPoolExecutor` on
those platforms.
.. nonce: hsCNgX
.. section: Core and Builtins
-If :func:`object.__ipow__` returns :const:`NotImplemented`, the operator
+If :func:`object.__ipow__` returns :data:`NotImplemented`, the operator
will correctly fall back to :func:`object.__pow__` and
:func:`object.__rpow__` as expected.
diff --git a/Misc/NEWS.d/3.11.0a1.rst b/Misc/NEWS.d/3.11.0a1.rst
index e8d4a02a11e0f9..754e782dfe661b 100644
--- a/Misc/NEWS.d/3.11.0a1.rst
+++ b/Misc/NEWS.d/3.11.0a1.rst
@@ -660,7 +660,7 @@ Karabas.
.. section: Core and Builtins
Parameter substitution of the union type with wrong types now raises
-``TypeError`` instead of returning ``NotImplemented``.
+``TypeError`` instead of returning :data:`NotImplemented`.
..
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]