stubalyzer.lookup module

class stubalyzer.lookup.LookupResult(symbol, containing_class)[source]

Bases: tuple

property containing_class

Class the symbol was found on

property symbol

Symbol that was found

stubalyzer.lookup.get_symbol_class(symbol: mypy.nodes.SymbolNode) Optional[mypy.nodes.TypeInfo][source]

Get the class the given symbol is defined on.


symbol – Symbol to retrieve the class of

stubalyzer.lookup.lookup_symbol(symbol_map: Dict[str, Union[mypy.nodes.Decorator, mypy.nodes.FuncDef, mypy.nodes.OverloadedFuncDef, mypy.nodes.Var, mypy.nodes.TypeInfo, mypy.nodes.TypeVarExpr, mypy.nodes.TypeAlias]], symbol_to_lookup: mypy.nodes.SymbolNode) LookupResult[source]

Find the given symbol in the symbol map.

Ideally the symbol is just found under the exact same fullname. If not and the symbol is a method, this will take the symbol’s class and look it up in the map and then try to resolve the symbol on that class using its method resolution order.

If the result of the lookup has a different fullname than the original symbol the given symbol is defined at a different point in the class hierarchy than expected.

  • symbol_map – Dictionary for looking up symbols by their full name

  • symbol_to_lookup – Symbol to search for


The found symbol (if any) and the class it was found on (if any)