Skip to content

Commit 0ba0ca0

Browse files
authored
gh-103373: Improve documentation for __mro_entries__ (#103374)
1 parent b22d021 commit 0ba0ca0

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
@@ -2086,11 +2086,15 @@ When a class definition is executed, the following steps occur:
20862086
Resolving MRO entries
20872087
^^^^^^^^^^^^^^^^^^^^^
20882088

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

20952099
.. seealso::
20962100

0 commit comments

Comments
 (0)