adaptix.type_tools package

Module contents

adaptix.type_tools.exec_type_checking(module: ~types.ModuleType, *, collector: ~collections.abc.Callable[[~ast.Module], list[~ast.stmt]] = <function make_fragments_collector.<locals>.collect_type_checking_only_fragments>) None

This function scans module source code, collects fragments under if TYPE_CHECKING and if typing.TYPE_CHECKING and executes them in the context of module. After these, all imports and type definitions became available at runtime for analysis.

By default, it ignores if with else branch.

Parameters:
  • module – A module for processing

  • collector – A function collecting code fragments to execute

adaptix.type_tools.make_fragments_collector(
*,
typing_modules: Sequence[str],
) Callable[[Module], list[stmt]]