module documentation

Solver for type equations.

Class TypeSolver Class for solving ~unknowns in type inference results.
Exception FlawedQuery Thrown if there is a fundamental flaw in the query.
Function convert_pytd Convert pytd with unknowns (structural types) to one with nominal types.
Function convert_string_type Convert a string representing a type back to a pytd type.
Function convert_string_type_list Like convert_string_type, but operate on a list.
Function extract_local Extract all classes that are not unknowns of call records of builtins.
Function insert_solution Replace ~unknown types in a pytd with the actual (solved) types.
Function log_info_mapping Print a raw type mapping. For debugging.
Function solve Solve the unknowns in a pytd AST using the standard Python builtins.
Constant MAX_DEPTH Undocumented
Variable log Undocumented
def convert_pytd(ast, builtins_pytd, protocols_pytd): (source)

Convert pytd with unknowns (structural types) to one with nominal types.

def convert_string_type(string_type, unknown, mapping, global_lookup, depth=0): (source)

Convert a string representing a type back to a pytd type.

def convert_string_type_list(types_as_string, unknown, mapping, global_lookup, depth=0): (source)

Like convert_string_type, but operate on a list.

def extract_local(ast): (source)

Extract all classes that are not unknowns of call records of builtins.

def insert_solution(result, mapping, global_lookup): (source)

Replace ~unknown types in a pytd with the actual (solved) types.

def log_info_mapping(mapping: Dict[str, AbstractSet[str]]): (source)

Print a raw type mapping. For debugging.

def solve(ast, builtins_pytd, protocols_pytd): (source)

Solve the unknowns in a pytd AST using the standard Python builtins. Args: ast: A pytd.TypeDeclUnit, containing classes named ~unknownXX. builtins_pytd: A pytd for builtins. protocols_pytd: A pytd for protocols. Returns: A tuple of (1) a dictionary (str->str) mapping unknown class names to known class names and (2) a pytd.TypeDeclUnit of the complete classes in ast.

MAX_DEPTH: int = (source)

Undocumented

Value
1

Undocumented