diff --git a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll index 529e90798ba..21fa6872864 100644 --- a/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll +++ b/python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll @@ -2118,6 +2118,19 @@ module DuckTyping { */ Function getInit(Class cls) { result = invokedFunctionFromClassConstruction(cls, "__init__") } + /** + * Holds if `cls` or any of its superclasses uses multiple inheritance, or + * has an unresolved base class. In these cases, our MRO approximation may + * resolve to the wrong `__init__`, so we should not flag argument mismatches. + */ + predicate hasUnreliableMro(Class cls) { + exists(Class sup | sup = getADirectSuperclass*(cls) | + exists(sup.getBase(1)) + or + hasUnresolvedBase(sup) + ) + } + /** * Holds if `f` overrides a method in a superclass with the same name. */