-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Open
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Python generally supports multiple inheritance, but only under certain conditions (the classes must have compatible memory layouts, compatible metaclasses, and a compatible MRO). This behavior is quite stable in practice but the documentation doesn't discuss it very much:
- https://docs.python.org/3/tutorial/classes.html#tut-multiple is a section of the tutorial covering multiple inheritance, but says nothing about the fact that multiple inhritance will sometimes fail
- https://docs.python.org/3/reference/datamodel.html#object.__slots__ mentions the effect of slots on multiple inheritance.
- https://docs.python.org/3/reference/datamodel.html#determining-the-appropriate-metaclass mentions that class creation will fail if no appropriate metaclass can be found.
I propose to add a section to the language reference (not the tutorial) about multiple inheritance, explaining how it works and when it doesn't.
Relatedly, I just posted a proposal to allow type checkers to better support this: https://discuss.python.org/t/solid-bases-for-detecting-incompatible-base-classes/99280
Linked PRs
OTheDev
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Projects
Status
Todo