Skip to content

Commit 00b157d

Browse files
committed
gh-62172: Document classify_class_attrs(), getabsfile(), and indentsize() in inspect
1 parent dd2faeb commit 00b157d

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

Doc/library/inspect.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,15 @@ Retrieving source code
736736
class, or function.
737737

738738

739+
.. function:: getabsfile(object)
740+
741+
Return an absolute path to the (text or binary) file in which an object
742+
was defined, normalized for the current platform using
743+
:func:`os.path.normcase`. This uses :func:`getsourcefile` and falls back
744+
to :func:`getfile` if no source file can be found. The idea is for each
745+
object to have a unique origin.
746+
747+
739748
.. function:: getmodule(object)
740749

741750
Try to guess which module an object was defined in. Return ``None``
@@ -791,6 +800,12 @@ Retrieving source code
791800
expanded to spaces.
792801

793802

803+
.. function:: indentsize(line)
804+
805+
Return the indentation size, in number of spaces, at the start of a line
806+
of text, expanding tabs using :meth:`str.expandtabs`.
807+
808+
794809
.. _inspect-signature-object:
795810

796811
Introspecting callables with the Signature object
@@ -1220,6 +1235,20 @@ function.
12201235
Classes and functions
12211236
---------------------
12221237

1238+
.. function:: classify_class_attrs(cls)
1239+
1240+
Return a list of ``Attribute(name, kind, defining_class, object)`` named
1241+
tuples for each attribute reported by ``dir(cls)``. *kind* is one of
1242+
``'class method'``, ``'static method'``, ``'property'``, ``'method'`` or
1243+
``'data'``, and *defining_class* is the class in *cls*'s :term:`MRO` (or
1244+
its metaclass's MRO) that defines the attribute. *object* is the
1245+
attribute value, retrieved with :func:`getattr` where possible, falling
1246+
back to a lookup in the defining class's ``__dict__``.
1247+
1248+
This is used internally by :mod:`pydoc` to build the class documentation
1249+
shown by :func:`help`.
1250+
1251+
12231252
.. function:: getclasstree(classes, unique=False)
12241253

12251254
Arrange the given list of classes into a hierarchy of nested lists. Where a

0 commit comments

Comments
 (0)