stubalyzer.collect module¶
API for analyzing Python stubs using mypy.
- stubalyzer.collect.IGNORED_MODULE_SYMBOLS = ['__doc__', '__name__', '__package__', '__file__', '__path__']¶
Module level definitions that will not be collected by collect_types.
- stubalyzer.collect.collect_types(symbol_node: mypy.nodes.SymbolNode, collected_types: Optional[Set[str]] = None) Iterable[Union[mypy.nodes.Decorator, mypy.nodes.FuncDef, mypy.nodes.OverloadedFuncDef, mypy.nodes.Var, mypy.nodes.TypeInfo, mypy.nodes.TypeVarExpr, mypy.nodes.TypeAlias]] [source]¶
Collect all relevant type definitions of the symbols in the given node.
- Parameters
symbol_node – any symbol node, e.g. MypyFile (BuildResult.graph.tree)
collected_types – used to avoid collecting duplicates
- stubalyzer.collect.get_stub_types(stubs_path: str, mypy_conf_path: str, root_path: Optional[str] = None) Iterable[Tuple[Union[mypy.nodes.Decorator, mypy.nodes.FuncDef, mypy.nodes.OverloadedFuncDef, mypy.nodes.Var, mypy.nodes.TypeInfo, mypy.nodes.TypeVarExpr, mypy.nodes.TypeAlias], str]] [source]¶
Analyze the stub files in stubs_path and return module and class definitions of stubs as symbol nodes.
Only relevant symbol nodes (e.g. for variables, functions, classes, methods) are returned. They contain the type annotation information.
- Parameters
stubs_path – where all the stub files are located
mypy_conf_path – path to mypy.ini
root_path – path to the code directory where the type analysis is started