Skip to main content

mro_lookup

Return the first node by MRO order that defines an attribute.

def mro_lookup(
cls: Any,
attr: string,
stop: Set[Any],
monkey_patched: Sequence
) - > Any

Return the first node by MRO order that defines an attribute.

Parameters

NameTypeDescription
clsAnyThe child class to begin the Method Resolution Order (MRO) traversal from.
attrstringThe name of the attribute to locate within the class hierarchy.
stopSet[Any]A set of types that, if encountered during traversal, will terminate the search.
monkey_patchedSequenceA list of module names used to validate attribute origins; if a stop class is reached and the attribute's module is not in this list, the stop class is returned to detect monkey-patched attributes.

Returns

TypeDescription
AnyThe class node that defines the attribute, or None if the attribute is not found within the search constraints.