I need two levels of abstract classes and a third level concrete class:
from abc import ABC
class Shape(ABC):
...
class Quad(ABC, Shape):
...
class Square(Quadrilateral)
...
This code generates TypeError: Cannot create a consistent method resolution
against the declaration of Quad
. I realize that the problem is a multiple inheritance ambiguity. Quad
doesn't know whether to derive certain functions directly from ABC
or from Shape
, but how do I fix it? I can't drop ABC
from Quad
's declaration because then it won't be abstract anymore.
Apparently, simply reversing the order of the parent classes to Quad fixes the problem. I'm still unclear on the underlying theory (although it can sort of be inferred), but at least my code is running now.