Skip to content

Commit 77359a8

Browse files
gh-103373: Improve documentation for __mro_entries__ (GH-103374)
(cherry picked from commit 0ba0ca0) Co-authored-by: Alex Waygood <[email protected]>
1 parent 7b03d0f commit 77359a8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Doc/reference/datamodel.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,11 +2085,15 @@ When a class definition is executed, the following steps occur:
20852085
Resolving MRO entries
20862086
^^^^^^^^^^^^^^^^^^^^^
20872087

2088-
If a base that appears in class definition is not an instance of :class:`type`,
2089-
then an ``__mro_entries__`` method is searched on it. If found, it is called
2090-
with the original bases tuple. This method must return a tuple of classes that
2091-
will be used instead of this base. The tuple may be empty, in such case
2092-
the original base is ignored.
2088+
.. method:: object.__mro_entries__(self, bases)
2089+
2090+
If a base that appears in a class definition is not an instance of
2091+
:class:`type`, then an ``__mro_entries__`` method is searched on the base.
2092+
If an ``__mro_entries__`` method is found, the base is substituted with the
2093+
result of a call to ``__mro_entries__`` when creating the class.
2094+
The method is called with the original bases tuple, and must return a tuple
2095+
of classes that will be used instead of the base. The returned tuple may be
2096+
empty: in these cases, the original base is ignored.
20932097

20942098
.. seealso::
20952099

0 commit comments

Comments
 (0)