Skip to content

Commit 45650d1

Browse files
authored
gh-101100: Fix most Sphinx nitpicks in inspect.rst (#112662)
1 parent c27b09c commit 45650d1

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

Doc/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@
163163
('envvar', 'USER'),
164164
('envvar', 'USERNAME'),
165165
('envvar', 'USERPROFILE'),
166+
# Deprecated function that was never documented:
167+
('py:func', 'getargspec'),
168+
('py:func', 'inspect.getargspec'),
166169
]
167170

168171
# Temporary undocumented names.

Doc/library/inspect.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
273273

274274
:func:`getmembers` will only return class attributes defined in the
275275
metaclass when the argument is a class and those attributes have been
276-
listed in the metaclass' custom :meth:`__dir__`.
276+
listed in the metaclass' custom :meth:`~object.__dir__`.
277277

278278

279279
.. function:: getmembers_static(object[, predicate])
@@ -487,12 +487,13 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
487487
has a :meth:`~object.__get__` method but not a :meth:`~object.__set__`
488488
method, but beyond that the set of attributes varies. A
489489
:attr:`~definition.__name__` attribute is usually
490-
sensible, and :attr:`__doc__` often is.
490+
sensible, and :attr:`!__doc__` often is.
491491

492492
Methods implemented via descriptors that also pass one of the other tests
493493
return ``False`` from the :func:`ismethoddescriptor` test, simply because the
494494
other tests promise more -- you can, e.g., count on having the
495-
:attr:`__func__` attribute (etc) when an object passes :func:`ismethod`.
495+
:ref:`__func__ <instance-methods>` attribute (etc) when an object passes
496+
:func:`ismethod`.
496497

497498

498499
.. function:: isdatadescriptor(object)
@@ -503,7 +504,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
503504
Examples are properties (defined in Python), getsets, and members. The
504505
latter two are defined in C and there are more specific tests available for
505506
those types, which is robust across Python implementations. Typically, data
506-
descriptors will also have :attr:`~definition.__name__` and :attr:`__doc__` attributes
507+
descriptors will also have :attr:`~definition.__name__` and :attr:`!__doc__` attributes
507508
(properties, getsets, and members have both of these attributes), but this is
508509
not guaranteed.
509510

@@ -1440,7 +1441,8 @@ Fetching attributes statically
14401441

14411442
Both :func:`getattr` and :func:`hasattr` can trigger code execution when
14421443
fetching or checking for the existence of attributes. Descriptors, like
1443-
properties, will be invoked and :meth:`__getattr__` and :meth:`__getattribute__`
1444+
properties, will be invoked and :meth:`~object.__getattr__` and
1445+
:meth:`~object.__getattribute__`
14441446
may be called.
14451447

14461448
For cases where you want passive introspection, like documentation tools, this
@@ -1450,7 +1452,8 @@ but avoids executing code when it fetches attributes.
14501452
.. function:: getattr_static(obj, attr, default=None)
14511453

14521454
Retrieve attributes without triggering dynamic lookup via the
1453-
descriptor protocol, :meth:`__getattr__` or :meth:`__getattribute__`.
1455+
descriptor protocol, :meth:`~object.__getattr__`
1456+
or :meth:`~object.__getattribute__`.
14541457

14551458
Note: this function may not be able to retrieve all attributes
14561459
that getattr can fetch (like dynamically created attributes)

Doc/reference/datamodel.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ code object; see the description of internal types below. The
634634
module.
635635

636636

637+
.. _instance-methods:
638+
637639
Instance methods
638640
^^^^^^^^^^^^^^^^
639641

Doc/whatsnew/2.6.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,8 +1677,9 @@ Some smaller changes made to the core Python language are:
16771677
(:issue:`1591665`)
16781678

16791679
* Instance method objects have new attributes for the object and function
1680-
comprising the method; the new synonym for :attr:`im_self` is
1681-
:attr:`__self__`, and :attr:`im_func` is also available as :attr:`__func__`.
1680+
comprising the method; the new synonym for :attr:`!im_self` is
1681+
:ref:`__self__ <instance-methods>`, and :attr:`!im_func` is also available as
1682+
:ref:`__func__ <instance-methods>`.
16821683
The old names are still supported in Python 2.6, but are gone in 3.0.
16831684

16841685
* An obscure change: when you use the :func:`locals` function inside a

Doc/whatsnew/2.7.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,8 @@ Some smaller changes made to the core Python language are:
860860
861861
* When using ``@classmethod`` and ``@staticmethod`` to wrap
862862
methods as class or static methods, the wrapper object now
863-
exposes the wrapped function as their :attr:`__func__` attribute.
863+
exposes the wrapped function as their :ref:`__func__ <instance-methods>`
864+
attribute.
864865
(Contributed by Amaury Forgeot d'Arc, after a suggestion by
865866
George Sakkis; :issue:`5982`.)
866867

0 commit comments

Comments
 (0)