first_common_ancestor¶
- pythonic_fp.gadgets.first_common_ancestor(cls1: type, cls2: type) type¶
Find the least upper bound in the inheritance graph of two classes.
Warning
This function can fail with a TypeError. Some error messages seen are
multiple bases have instance lay-out conflict
type ‘bool’ is not an acceptable base type
This happens frequently when the function is given Python builtin types or in multiple inheritance situations.
- Parameters:
cls1 – A class in the inheritance hierarchy.
cls2 – A class in the inheritance hierarchy.
- Returns:
First common ancestor based on getmro order.
- Raises:
TypeError – Raised when no common ancestor or not caught when raised by
inspect.getmro.