Skip to content

Commit 179b134

Browse files
[3.12] gh-101100: Fix Sphinx warnings about list methods (GH-127054) (#127512)
Co-authored-by: Yuki Kobayashi <drsuaimqjgar@gmail.com>
1 parent 97fd09f commit 179b134

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

Doc/library/collections.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,10 @@ sequence of key-value pairs into a dictionary of lists:
783783

784784
When each key is encountered for the first time, it is not already in the
785785
mapping; so an entry is automatically created using the :attr:`~defaultdict.default_factory`
786-
function which returns an empty :class:`list`. The :meth:`list.append`
786+
function which returns an empty :class:`list`. The :meth:`!list.append`
787787
operation then attaches the value to the new list. When keys are encountered
788788
again, the look-up proceeds normally (returning the list for that key) and the
789-
:meth:`list.append` operation adds another value to the list. This technique is
789+
:meth:`!list.append` operation adds another value to the list. This technique is
790790
simpler and faster than an equivalent technique using :meth:`dict.setdefault`:
791791

792792
>>> d = {}

Doc/tools/.nitignore

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ Doc/library/xmlrpc.server.rst
8989
Doc/library/zlib.rst
9090
Doc/reference/compound_stmts.rst
9191
Doc/reference/datamodel.rst
92-
Doc/tutorial/datastructures.rst
9392
Doc/using/windows.rst
9493
Doc/whatsnew/2.4.rst
9594
Doc/whatsnew/2.5.rst

Doc/tutorial/datastructures.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ Using Lists as Stacks
142142

143143
The list methods make it very easy to use a list as a stack, where the last
144144
element added is the first element retrieved ("last-in, first-out"). To add an
145-
item to the top of the stack, use :meth:`~list.append`. To retrieve an item from the
146-
top of the stack, use :meth:`~list.pop` without an explicit index. For example::
145+
item to the top of the stack, use :meth:`!~list.append`. To retrieve an item from the
146+
top of the stack, use :meth:`!~list.pop` without an explicit index. For example::
147147

148148
>>> stack = [3, 4, 5]
149149
>>> stack.append(6)
@@ -340,7 +340,7 @@ The :keyword:`!del` statement
340340
=============================
341341

342342
There is a way to remove an item from a list given its index instead of its
343-
value: the :keyword:`del` statement. This differs from the :meth:`~list.pop` method
343+
value: the :keyword:`del` statement. This differs from the :meth:`!~list.pop` method
344344
which returns a value. The :keyword:`!del` statement can also be used to remove
345345
slices from a list or clear the entire list (which we did earlier by assignment
346346
of an empty list to the slice). For example::
@@ -500,8 +500,8 @@ any immutable type; strings and numbers can always be keys. Tuples can be used
500500
as keys if they contain only strings, numbers, or tuples; if a tuple contains
501501
any mutable object either directly or indirectly, it cannot be used as a key.
502502
You can't use lists as keys, since lists can be modified in place using index
503-
assignments, slice assignments, or methods like :meth:`~list.append` and
504-
:meth:`~list.extend`.
503+
assignments, slice assignments, or methods like :meth:`!~list.append` and
504+
:meth:`!~list.extend`.
505505

506506
It is best to think of a dictionary as a set of *key: value* pairs,
507507
with the requirement that the keys are unique (within one dictionary). A pair of

0 commit comments

Comments
 (0)