Why is this an ambiguous MRO?

To be "consistent" the MRO should satisfy these constraints:

  1. If a class inherits from multiple superclasses, the ones it lists earlier in the superclass list should come earlier in the MRO than the ones it lists later.
  2. Every class in the MRO should come before any of its superclasses.

Your proposed hierarchy does not have any possible ordering meeting these constraints. Because Third is defined to inherit from First before Second, First should come before Second in the MRO. But because Second inherits from First, Second should come before First in the MRO. This contradiction cannot be reconciled.

You can read more about the precise method Python uses to compute the MRO, which is called the C3 linearization algorithm.


Python internally thinks not to have super class before sub-class.

According to your code. After Scanning or loading the classes, Python thinks the method resolution has to be:

Third -> Second -> First

Here, First is the super class of Second.

But while executing, after checking Third it confronts First which is the super class of Second.

Hence the TypeError.

class Third(First, Second): # Wrong
class Third(Second, First): # Correct