def preserve_full_cache(graph: Graph, manager: BuildManager) -> SavedCache: """Preserve every module with an AST in the graph, including modules with errors.""" saved_cache = {} for id, state in graph.items(): assert state.id == id if state.tree is not None: meta = state.meta if meta is None: # No metadata, likely because of an error. We still want to retain the AST. # There is no corresponding JSON so create partial "memory-only" metadata. assert state.path dep_prios = state.dependency_priorities() meta = memory_only_cache_meta( id, state.path, state.dependencies, state.suppressed, list(state.child_modules), dep_prios, state.source_hash, state.ignore_all, manager) else: meta = meta._replace(memory_only=True) saved_cache[id] = (meta, state.tree, state.type_map()) return saved_cache
def get_module_to_path_map(graph: Graph) -> Dict[str, str]: return {module: node.xpath for module, node in graph.items()}
def extract_type_maps(graph: Graph) -> Dict[str, Dict[Expression, Type]]: return {id: state.type_map() for id, state in graph.items()}
def extract_type_maps(graph: Graph) -> Dict[str, Dict[Expression, Type]]: # This is used to export information used only by the testmerge harness. return {id: state.type_map() for id, state in graph.items() if state.tree}