I’m referring to “Fluent Python” by Luciano Ramalho. In chapter 12, there’s a section “Coping with Multiple Inheritance” where the author suggests a few best practices, such as:
- Distinguish Interface Inheritance from Implementation Inheritance
- Make Interfaces explicit with ABCs (abstract base classes)
- Use Mixins for Code Reuse
If a class is designed to provide method implementations for reuse by multiple unrelated subclasses, without implying an “is-a” relationship, it should be an explicit mixin class. Conceptually, a mixin does not define a new type; it merely bundles methods for reuse. A mixin should never be instantiated, and concrete classes should not inherit only from a mixin. Each mixin should provide a single specific behavior, implementing few and very closely related methods.
Emphasis mine. I get the “shouldn’t be instantiated” part; it’s not meant to be useful on its own. I don’t get the “concrete classes should not inherit only from a mixin”. Why not? How would that lead to a bad design?