Skip to content

[3.11] gh-103373: Improve documentation for __mro_entries__ (GH-103374) #103376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2085,11 +2085,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