Skip to content

Commit

Permalink
pythongh-103373: Improve documentation for __mro_entries__ (python#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Apr 8, 2023
1 parent b22d021 commit 0ba0ca0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2086,11 +2086,15 @@ When a class definition is executed, the following steps occur:
Resolving MRO entries
^^^^^^^^^^^^^^^^^^^^^

If a base that appears in class definition is not an instance of :class:`type`,
then an ``__mro_entries__`` method is searched on it. If found, it is called
with the original bases tuple. This method must return a tuple of classes that
will be used instead of this base. The tuple may be empty, in such case
the original base is ignored.
.. method:: object.__mro_entries__(self, bases)

If a base that appears in a class definition is not an instance of
:class:`type`, then an ``__mro_entries__`` method is searched on the base.
If an ``__mro_entries__`` method is found, the base is substituted with the
result of a call to ``__mro_entries__`` when creating the class.
The method is called with the original bases tuple, and must return a tuple
of classes that will be used instead of the base. The returned tuple may be
empty: in these cases, the original base is ignored.

.. seealso::

Expand Down

0 comments on commit 0ba0ca0

Please sign in to comment.