Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 240e5f6

Browse filesBrowse files
[3.12] Docs: mark up NotImplemented using the :data: role throughout the docs (GH-116135) (#116147)
(cherry picked from commit dbe44f1) Co-authored-by: Erlend E. Aasland <erlend@python.org>
1 parent d49fdc8 commit 240e5f6
Copy full SHA for 240e5f6

File tree

Expand file treeCollapse file tree

16 files changed

+39
-39
lines changed
Filter options
Expand file treeCollapse file tree

16 files changed

+39
-39
lines changed

‎Doc/library/abc.rst

Copy file name to clipboardExpand all lines: Doc/library/abc.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
101101
subclass of the ABC. (This class method is called from the
102102
:meth:`~class.__subclasscheck__` method of the ABC.)
103103

104-
This method should return ``True``, ``False`` or ``NotImplemented``. If
104+
This method should return ``True``, ``False`` or :data:`NotImplemented`. If
105105
it returns ``True``, the *subclass* is considered a subclass of this ABC.
106106
If it returns ``False``, the *subclass* is not considered a subclass of
107107
this ABC, even if it would normally be one. If it returns
108-
``NotImplemented``, the subclass check is continued with the usual
108+
:data:`!NotImplemented`, the subclass check is continued with the usual
109109
mechanism.
110110

111111
.. XXX explain the "usual mechanism"

‎Doc/library/constants.rst

Copy file name to clipboardExpand all lines: Doc/library/constants.rst
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,27 @@ A small number of constants live in the built-in namespace. They are:
3333
the other type; may be returned by the in-place binary special methods
3434
(e.g. :meth:`~object.__imul__`, :meth:`~object.__iand__`, etc.) for the same purpose.
3535
It should not be evaluated in a boolean context.
36-
``NotImplemented`` is the sole instance of the :data:`types.NotImplementedType` type.
36+
:data:`!NotImplemented` is the sole instance of the :data:`types.NotImplementedType` type.
3737

3838
.. note::
3939

40-
When a binary (or in-place) method returns ``NotImplemented`` the
40+
When a binary (or in-place) method returns :data:`!NotImplemented` the
4141
interpreter will try the reflected operation on the other type (or some
4242
other fallback, depending on the operator). If all attempts return
43-
``NotImplemented``, the interpreter will raise an appropriate exception.
44-
Incorrectly returning ``NotImplemented`` will result in a misleading
45-
error message or the ``NotImplemented`` value being returned to Python code.
43+
:data:`!NotImplemented`, the interpreter will raise an appropriate exception.
44+
Incorrectly returning :data:`!NotImplemented` will result in a misleading
45+
error message or the :data:`!NotImplemented` value being returned to Python code.
4646

4747
See :ref:`implementing-the-arithmetic-operations` for examples.
4848

4949
.. note::
5050

51-
``NotImplementedError`` and ``NotImplemented`` are not interchangeable,
51+
``NotImplementedError`` and :data:`!NotImplemented` are not interchangeable,
5252
even though they have similar names and purposes.
5353
See :exc:`NotImplementedError` for details on when to use it.
5454

5555
.. versionchanged:: 3.9
56-
Evaluating ``NotImplemented`` in a boolean context is deprecated. While
56+
Evaluating :data:`!NotImplemented` in a boolean context is deprecated. While
5757
it currently evaluates as true, it will emit a :exc:`DeprecationWarning`.
5858
It will raise a :exc:`TypeError` in a future version of Python.
5959

‎Doc/library/exceptions.rst

Copy file name to clipboardExpand all lines: Doc/library/exceptions.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ The following exceptions are the exceptions that are usually raised.
335335

336336
.. note::
337337

338-
``NotImplementedError`` and ``NotImplemented`` are not interchangeable,
338+
``NotImplementedError`` and :data:`NotImplemented` are not interchangeable,
339339
even though they have similar names and purposes. See
340-
:data:`NotImplemented` for details on when to use it.
340+
:data:`!NotImplemented` for details on when to use it.
341341

342342
.. exception:: OSError([arg])
343343
OSError(errno, strerror[, filename[, winerror[, filename2]]])

‎Doc/library/importlib.rst

Copy file name to clipboardExpand all lines: Doc/library/importlib.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ ABC hierarchy::
265265
when invalidating the caches of all finders on :data:`sys.meta_path`.
266266

267267
.. versionchanged:: 3.4
268-
Returns ``None`` when called instead of ``NotImplemented``.
268+
Returns ``None`` when called instead of :data:`NotImplemented`.
269269

270270

271271
.. class:: PathEntryFinder

‎Doc/library/numbers.rst

Copy file name to clipboardExpand all lines: Doc/library/numbers.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Complex``. I'll consider ``a + b``:
166166
2. If ``A`` falls back to the boilerplate code, and it were to
167167
return a value from :meth:`~object.__add__`, we'd miss the possibility
168168
that ``B`` defines a more intelligent :meth:`~object.__radd__`, so the
169-
boilerplate should return :const:`NotImplemented` from
169+
boilerplate should return :data:`NotImplemented` from
170170
:meth:`!__add__`. (Or ``A`` may not implement :meth:`!__add__` at
171171
all.)
172172
3. Then ``B``'s :meth:`~object.__radd__` gets a chance. If it accepts

‎Doc/library/pickle.rst

Copy file name to clipboardExpand all lines: Doc/library/pickle.rst
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ The :mod:`pickle` module exports three classes, :class:`Pickler`,
373373
Special reducer that can be defined in :class:`Pickler` subclasses. This
374374
method has priority over any reducer in the :attr:`dispatch_table`. It
375375
should conform to the same interface as a :meth:`~object.__reduce__` method, and
376-
can optionally return ``NotImplemented`` to fallback on
376+
can optionally return :data:`NotImplemented` to fallback on
377377
:attr:`dispatch_table`-registered reducers to pickle ``obj``.
378378

379379
For a detailed example, see :ref:`reducer_override`.
@@ -495,7 +495,7 @@ What can be pickled and unpickled?
495495
The following types can be pickled:
496496

497497
* built-in constants (``None``, ``True``, ``False``, ``Ellipsis``, and
498-
``NotImplemented``);
498+
:data:`NotImplemented`);
499499

500500
* integers, floating-point numbers, complex numbers;
501501

@@ -897,7 +897,7 @@ functions and classes.
897897
For those cases, it is possible to subclass from the :class:`Pickler` class and
898898
implement a :meth:`~Pickler.reducer_override` method. This method can return an
899899
arbitrary reduction tuple (see :meth:`~object.__reduce__`). It can alternatively return
900-
``NotImplemented`` to fallback to the traditional behavior.
900+
:data:`NotImplemented` to fallback to the traditional behavior.
901901

902902
If both the :attr:`~Pickler.dispatch_table` and
903903
:meth:`~Pickler.reducer_override` are defined, then

‎Doc/library/stdtypes.rst

Copy file name to clipboardExpand all lines: Doc/library/stdtypes.rst
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5447,10 +5447,10 @@ The NotImplemented Object
54475447

54485448
This object is returned from comparisons and binary operations when they are
54495449
asked to operate on types they don't support. See :ref:`comparisons` for more
5450-
information. There is exactly one ``NotImplemented`` object.
5451-
``type(NotImplemented)()`` produces the singleton instance.
5450+
information. There is exactly one :data:`NotImplemented` object.
5451+
:code:`type(NotImplemented)()` produces the singleton instance.
54525452

5453-
It is written as ``NotImplemented``.
5453+
It is written as :code:`NotImplemented`.
54545454

54555455

54565456
.. _typesinternal:

‎Doc/library/unittest.mock.rst

Copy file name to clipboardExpand all lines: Doc/library/unittest.mock.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,10 +2094,10 @@ to change the default.
20942094

20952095
Methods and their defaults:
20962096

2097-
* ``__lt__``: ``NotImplemented``
2098-
* ``__gt__``: ``NotImplemented``
2099-
* ``__le__``: ``NotImplemented``
2100-
* ``__ge__``: ``NotImplemented``
2097+
* ``__lt__``: :data:`NotImplemented`
2098+
* ``__gt__``: :data:`!NotImplemented`
2099+
* ``__le__``: :data:`!NotImplemented`
2100+
* ``__ge__``: :data:`!NotImplemented`
21012101
* ``__int__``: ``1``
21022102
* ``__contains__``: ``False``
21032103
* ``__len__``: ``0``

‎Doc/reference/datamodel.rst

Copy file name to clipboardExpand all lines: Doc/reference/datamodel.rst
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ NotImplemented
159159
.. index:: pair: object; NotImplemented
160160

161161
This type has a single value. There is a single object with this value. This
162-
object is accessed through the built-in name ``NotImplemented``. Numeric methods
162+
object is accessed through the built-in name :data:`NotImplemented`. Numeric methods
163163
and rich comparison methods should return this value if they do not implement the
164164
operation for the operands provided. (The interpreter will then try the
165165
reflected operation, or some other fallback, depending on the operator.) It
@@ -170,7 +170,7 @@ See
170170
for more details.
171171

172172
.. versionchanged:: 3.9
173-
Evaluating ``NotImplemented`` in a boolean context is deprecated. While
173+
Evaluating :data:`NotImplemented` in a boolean context is deprecated. While
174174
it currently evaluates as true, it will emit a :exc:`DeprecationWarning`.
175175
It will raise a :exc:`TypeError` in a future version of Python.
176176

@@ -1780,18 +1780,18 @@ Basic customization
17801780
``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls
17811781
``x.__ge__(y)``.
17821782

1783-
A rich comparison method may return the singleton ``NotImplemented`` if it does
1783+
A rich comparison method may return the singleton :data:`NotImplemented` if it does
17841784
not implement the operation for a given pair of arguments. By convention,
17851785
``False`` and ``True`` are returned for a successful comparison. However, these
17861786
methods can return any value, so if the comparison operator is used in a Boolean
17871787
context (e.g., in the condition of an ``if`` statement), Python will call
17881788
:func:`bool` on the value to determine if the result is true or false.
17891789

17901790
By default, ``object`` implements :meth:`__eq__` by using ``is``, returning
1791-
``NotImplemented`` in the case of a false comparison:
1791+
:data:`NotImplemented` in the case of a false comparison:
17921792
``True if x is y else NotImplemented``. For :meth:`__ne__`, by default it
17931793
delegates to :meth:`__eq__` and inverts the result unless it is
1794-
``NotImplemented``. There are no other implied relationships among the
1794+
:data:`!NotImplemented`. There are no other implied relationships among the
17951795
comparison operators or default implementations; for example, the truth of
17961796
``(x<y or x==y)`` does not imply ``x<=y``. To automatically generate ordering
17971797
operations from a single root operation, see :func:`functools.total_ordering`.
@@ -2821,7 +2821,7 @@ through the object's keys; for sequences, it should iterate through the values.
28212821
Called to implement :func:`operator.length_hint`. Should return an estimated
28222822
length for the object (which may be greater or less than the actual length).
28232823
The length must be an integer ``>=`` 0. The return value may also be
2824-
:const:`NotImplemented`, which is treated the same as if the
2824+
:data:`NotImplemented`, which is treated the same as if the
28252825
``__length_hint__`` method didn't exist at all. This method is purely an
28262826
optimization and is never required for correctness.
28272827

@@ -2973,7 +2973,7 @@ left undefined.
29732973
function is to be supported.
29742974

29752975
If one of those methods does not support the operation with the supplied
2976-
arguments, it should return ``NotImplemented``.
2976+
arguments, it should return :data:`NotImplemented`.
29772977

29782978

29792979
.. method:: object.__radd__(self, other)
@@ -3003,7 +3003,7 @@ left undefined.
30033003
types. [#]_ For instance, to evaluate the expression ``x - y``, where *y* is
30043004
an instance of a class that has an :meth:`__rsub__` method,
30053005
``type(y).__rsub__(y, x)`` is called if ``type(x).__sub__(x, y)`` returns
3006-
*NotImplemented*.
3006+
:data:`NotImplemented`.
30073007

30083008
.. index:: pair: built-in function; pow
30093009

@@ -3495,7 +3495,7 @@ An example of an asynchronous context manager class::
34953495
the behavior that ``None`` is not callable.
34963496
34973497
.. [#] "Does not support" here means that the class has no such method, or
3498-
the method returns ``NotImplemented``. Do not set the method to
3498+
the method returns :data:`NotImplemented`. Do not set the method to
34993499
``None`` if you want to force fallback to the right operand's reflected
35003500
method—that will instead have the opposite effect of explicitly
35013501
*blocking* such fallback.

‎Doc/reference/expressions.rst

Copy file name to clipboardExpand all lines: Doc/reference/expressions.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ built-in types.
15321532
``x == x`` are all false, while ``x != x`` is true. This behavior is
15331533
compliant with IEEE 754.
15341534

1535-
* ``None`` and ``NotImplemented`` are singletons. :PEP:`8` advises that
1535+
* ``None`` and :data:`NotImplemented` are singletons. :PEP:`8` advises that
15361536
comparisons for singletons should always be done with ``is`` or ``is not``,
15371537
never the equality operators.
15381538

‎Doc/whatsnew/2.7.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/2.7.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ changes, or look through the Subversion logs for all the details.
11301130
(Added by Raymond Hettinger; :issue:`1818`.)
11311131

11321132
Finally, the :class:`~collections.abc.Mapping` abstract base class now
1133-
returns :const:`NotImplemented` if a mapping is compared to
1133+
returns :data:`NotImplemented` if a mapping is compared to
11341134
another type that isn't a :class:`Mapping`.
11351135
(Fixed by Daniel Stutzbach; :issue:`8729`.)
11361136

‎Doc/whatsnew/3.10.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.10.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ Other Language Changes
828828
:meth:`~object.__index__` method).
829829
(Contributed by Serhiy Storchaka in :issue:`37999`.)
830830
831-
* If :func:`object.__ipow__` returns :const:`NotImplemented`, the operator will
831+
* If :func:`object.__ipow__` returns :data:`NotImplemented`, the operator will
832832
correctly fall back to :func:`object.__pow__` and :func:`object.__rpow__` as expected.
833833
(Contributed by Alex Shkop in :issue:`38302`.)
834834

‎Doc/whatsnew/3.4.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.4.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ multiple implementations of an operation that allows it to work with
872872
PEP written and implemented by Łukasz Langa.
873873

874874
:func:`~functools.total_ordering` now supports a return value of
875-
:const:`NotImplemented` from the underlying comparison function. (Contributed
875+
:data:`NotImplemented` from the underlying comparison function. (Contributed
876876
by Katie Miller in :issue:`10042`.)
877877

878878
A pure-python version of the :func:`~functools.partial` function is now in the

‎Doc/whatsnew/3.9.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.9.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ Changes in the Python API
11261126
``logging.getLogger(__name__)`` in some top-level module called ``'root.py'``.
11271127
(Contributed by Vinay Sajip in :issue:`37742`.)
11281128

1129-
* Division handling of :class:`~pathlib.PurePath` now returns ``NotImplemented``
1129+
* Division handling of :class:`~pathlib.PurePath` now returns :data:`NotImplemented`
11301130
instead of raising a :exc:`TypeError` when passed something other than an
11311131
instance of ``str`` or :class:`~pathlib.PurePath`. This allows creating
11321132
compatible classes that don't inherit from those mentioned types.

‎Misc/NEWS.d/3.10.0a6.rst

Copy file name to clipboardExpand all lines: Misc/NEWS.d/3.10.0a6.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ tests that are unrelated to :class:`ProcessPoolExecutor` on those platforms.
158158
.. nonce: hsCNgX
159159
.. section: Core and Builtins
160160
161-
If :func:`object.__ipow__` returns :const:`NotImplemented`, the operator
161+
If :func:`object.__ipow__` returns :data:`NotImplemented`, the operator
162162
will correctly fall back to :func:`object.__pow__` and
163163
:func:`object.__rpow__` as expected.
164164

‎Misc/NEWS.d/3.11.0a1.rst

Copy file name to clipboardExpand all lines: Misc/NEWS.d/3.11.0a1.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ Karabas.
660660
.. section: Core and Builtins
661661
662662
Parameter substitution of the union type with wrong types now raises
663-
``TypeError`` instead of returning ``NotImplemented``.
663+
``TypeError`` instead of returning :data:`NotImplemented`.
664664

665665
..
666666

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.