mirror of
https://github.com/python/cpython.git
synced 2025-10-02 05:12:23 +00:00
gh-103373: Improve documentation for __mro_entries__
(GH-103374)
(cherry picked from commit 0ba0ca05d2
)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
7b03d0f7c5
commit
77359a86b8
1 changed files with 9 additions and 5 deletions
|
@ -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::
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue