Skip to content

Commit da99133

Browse files
authored
GH-101100: Fix reference warnings for __getitem__ (#110118)
1 parent d144749 commit da99133

20 files changed

+38
-38
lines changed

Doc/glossary.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ Glossary
636636
iterables include all sequence types (such as :class:`list`, :class:`str`,
637637
and :class:`tuple`) and some non-sequence types like :class:`dict`,
638638
:term:`file objects <file object>`, and objects of any classes you define
639-
with an :meth:`__iter__` method or with a :meth:`__getitem__` method
639+
with an :meth:`__iter__` method or with a :meth:`~object.__getitem__` method
640640
that implements :term:`sequence` semantics.
641641

642642
Iterables can be
@@ -1078,17 +1078,17 @@ Glossary
10781078

10791079
sequence
10801080
An :term:`iterable` which supports efficient element access using integer
1081-
indices via the :meth:`__getitem__` special method and defines a
1081+
indices via the :meth:`~object.__getitem__` special method and defines a
10821082
:meth:`__len__` method that returns the length of the sequence.
10831083
Some built-in sequence types are :class:`list`, :class:`str`,
10841084
:class:`tuple`, and :class:`bytes`. Note that :class:`dict` also
1085-
supports :meth:`__getitem__` and :meth:`__len__`, but is considered a
1085+
supports :meth:`~object.__getitem__` and :meth:`__len__`, but is considered a
10861086
mapping rather than a sequence because the lookups use arbitrary
10871087
:term:`immutable` keys rather than integers.
10881088

10891089
The :class:`collections.abc.Sequence` abstract base class
10901090
defines a much richer interface that goes beyond just
1091-
:meth:`__getitem__` and :meth:`__len__`, adding :meth:`count`,
1091+
:meth:`~object.__getitem__` and :meth:`__len__`, adding :meth:`count`,
10921092
:meth:`index`, :meth:`__contains__`, and
10931093
:meth:`__reversed__`. Types that implement this expanded
10941094
interface can be registered explicitly using

Doc/library/abc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ a helper class :class:`ABC` to alternatively define ABCs through inheritance:
154154
Finally, the last line makes ``Foo`` a virtual subclass of ``MyIterable``,
155155
even though it does not define an :meth:`~iterator.__iter__` method (it uses
156156
the old-style iterable protocol, defined in terms of :meth:`__len__` and
157-
:meth:`__getitem__`). Note that this will not make ``get_iterator``
157+
:meth:`~object.__getitem__`). Note that this will not make ``get_iterator``
158158
available as a method of ``Foo``, so it is provided separately.
159159

160160

Doc/library/collections.abc.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ ABC Inherits from Abstract Methods Mi
192192
.. [2] Checking ``isinstance(obj, Iterable)`` detects classes that are
193193
registered as :class:`Iterable` or that have an :meth:`__iter__`
194194
method, but it does not detect classes that iterate with the
195-
:meth:`__getitem__` method. The only reliable way to determine
195+
:meth:`~object.__getitem__` method. The only reliable way to determine
196196
whether an object is :term:`iterable` is to call ``iter(obj)``.
197197
198198
@@ -222,7 +222,7 @@ Collections Abstract Base Classes -- Detailed Descriptions
222222

223223
Checking ``isinstance(obj, Iterable)`` detects classes that are registered
224224
as :class:`Iterable` or that have an :meth:`__iter__` method, but it does
225-
not detect classes that iterate with the :meth:`__getitem__` method.
225+
not detect classes that iterate with the :meth:`~object.__getitem__` method.
226226
The only reliable way to determine whether an object is :term:`iterable`
227227
is to call ``iter(obj)``.
228228

@@ -262,8 +262,8 @@ Collections Abstract Base Classes -- Detailed Descriptions
262262

263263
Implementation note: Some of the mixin methods, such as
264264
:meth:`__iter__`, :meth:`__reversed__` and :meth:`index`, make
265-
repeated calls to the underlying :meth:`__getitem__` method.
266-
Consequently, if :meth:`__getitem__` is implemented with constant
265+
repeated calls to the underlying :meth:`~object.__getitem__` method.
266+
Consequently, if :meth:`~object.__getitem__` is implemented with constant
267267
access speed, the mixin methods will have linear performance;
268268
however, if the underlying method is linear (as it would be with a
269269
linked list), the mixins will have quadratic performance and will

Doc/library/collections.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,12 +743,12 @@ stack manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``,
743743
If calling :attr:`default_factory` raises an exception this exception is
744744
propagated unchanged.
745745

746-
This method is called by the :meth:`__getitem__` method of the
746+
This method is called by the :meth:`~object.__getitem__` method of the
747747
:class:`dict` class when the requested key is not found; whatever it
748-
returns or raises is then returned or raised by :meth:`__getitem__`.
748+
returns or raises is then returned or raised by :meth:`~object.__getitem__`.
749749

750750
Note that :meth:`__missing__` is *not* called for any operations besides
751-
:meth:`__getitem__`. This means that :meth:`get` will, like normal
751+
:meth:`~object.__getitem__`. This means that :meth:`get` will, like normal
752752
dictionaries, return ``None`` as a default rather than using
753753
:attr:`default_factory`.
754754

Doc/library/email.compat32-message.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ Here are the methods of the :class:`Message` class:
367367
.. method:: get(name, failobj=None)
368368

369369
Return the value of the named header field. This is identical to
370-
:meth:`__getitem__` except that optional *failobj* is returned if the
370+
:meth:`~object.__getitem__` except that optional *failobj* is returned if the
371371
named header is missing (defaults to ``None``).
372372

373373
Here are some additional useful methods:

Doc/library/email.message.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ message objects.
247247
.. method:: get(name, failobj=None)
248248

249249
Return the value of the named header field. This is identical to
250-
:meth:`__getitem__` except that optional *failobj* is returned if the
250+
:meth:`~object.__getitem__` except that optional *failobj* is returned if the
251251
named header is missing (*failobj* defaults to ``None``).
252252

253253

Doc/library/functions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ are always available. They are listed here in alphabetical order.
983983
differently depending on the presence of the second argument. Without a
984984
second argument, *object* must be a collection object which supports the
985985
:term:`iterable` protocol (the :meth:`__iter__` method), or it must support
986-
the sequence protocol (the :meth:`__getitem__` method with integer arguments
986+
the sequence protocol (the :meth:`~object.__getitem__` method with integer arguments
987987
starting at ``0``). If it does not support either of those protocols,
988988
:exc:`TypeError` is raised. If the second argument, *sentinel*, is given,
989989
then *object* must be a callable object. The iterator created in this case
@@ -1563,7 +1563,7 @@ are always available. They are listed here in alphabetical order.
15631563

15641564
Return a reverse :term:`iterator`. *seq* must be an object which has
15651565
a :meth:`__reversed__` method or supports the sequence protocol (the
1566-
:meth:`__len__` method and the :meth:`__getitem__` method with integer
1566+
:meth:`__len__` method and the :meth:`~object.__getitem__` method with integer
15671567
arguments starting at ``0``).
15681568

15691569

Doc/library/mailbox.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Supported mailbox formats are Maildir, mbox, MH, Babyl, and MMDF.
167167
Return a representation of the message corresponding to *key*. If no such
168168
message exists, *default* is returned if the method was called as
169169
:meth:`get` and a :exc:`KeyError` exception is raised if the method was
170-
called as :meth:`__getitem__`. The message is represented as an instance
170+
called as :meth:`~object.__getitem__`. The message is represented as an instance
171171
of the appropriate format-specific :class:`Message` subclass unless a
172172
custom message factory was specified when the :class:`Mailbox` instance
173173
was initialized.

Doc/library/operator.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ expect a function argument.
306306
itemgetter(*items)
307307
308308
Return a callable object that fetches *item* from its operand using the
309-
operand's :meth:`__getitem__` method. If multiple items are specified,
309+
operand's :meth:`~object.__getitem__` method. If multiple items are specified,
310310
returns a tuple of lookup values. For example:
311311

312312
* After ``f = itemgetter(2)``, the call ``f(r)`` returns ``r[2]``.
@@ -326,7 +326,7 @@ expect a function argument.
326326
return tuple(obj[item] for item in items)
327327
return g
328328

329-
The items can be any type accepted by the operand's :meth:`__getitem__`
329+
The items can be any type accepted by the operand's :meth:`~object.__getitem__`
330330
method. Dictionaries accept any :term:`hashable` value. Lists, tuples, and
331331
strings accept an index or a slice:
332332

Doc/library/stdtypes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,7 @@ expression support in the :mod:`re` module).
22672267

22682268
Return a copy of the string in which each character has been mapped through
22692269
the given translation table. The table must be an object that implements
2270-
indexing via :meth:`__getitem__`, typically a :term:`mapping` or
2270+
indexing via :meth:`~object.__getitem__`, typically a :term:`mapping` or
22712271
:term:`sequence`. When indexed by a Unicode ordinal (an integer), the
22722272
table object can do any of the following: return a Unicode ordinal or a
22732273
string, to map the character to one or more other characters; return

0 commit comments

Comments
 (0)