MCPcopy Index your code
hub / github.com/python/mypy / process_stale_scc_interface

Function process_stale_scc_interface

mypy/build.py:4863–4930  ·  view source on GitHub ↗

Process the modules' interfaces in one SCC from source code.

(
    graph: Graph, ascc: SCC, manager: BuildManager, from_cache: set[str]
)

Source from the content-addressed store, hash-verified

4861
4862
4863def process_stale_scc_interface(
4864 graph: Graph, ascc: SCC, manager: BuildManager, from_cache: set[str]
4865) -> list[tuple[str, ModuleResult, str]]:
4866 """Process the modules' interfaces in one SCC from source code."""
4867 # First verify if all transitive dependencies are loaded in the current process.
4868 t0 = time.time()
4869 maybe_load_deps(graph, ascc, manager)
4870 t1 = time.time()
4871 # Process the SCC in stable order.
4872 scc = order_ascc_ex(graph, ascc)
4873
4874 t2 = time.time()
4875 stale = scc
4876 for id in stale:
4877 # Re-generate import errors in case this module was loaded from the cache.
4878 # Deserialized states all have meta=None, so the caller should specify
4879 # explicitly which of them are from cache.
4880 if id in from_cache:
4881 graph[id].verify_dependencies(suppressed_only=True)
4882 mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
4883
4884 t3 = time.time()
4885 # Track what modules aren't yet done, so we can finish them as soon
4886 # as possible, saving memory.
4887 unfinished_modules = set(stale)
4888 for id in stale:
4889 graph[id].type_check_first_pass(recurse_into_functions=False)
4890 if not graph[id].type_checker().deferred_nodes:
4891 unfinished_modules.discard(id)
4892 while unfinished_modules:
4893 for id in stale:
4894 if id not in unfinished_modules:
4895 continue
4896 if not graph[id].type_check_second_pass(recurse_into_functions=False):
4897 unfinished_modules.discard(id)
4898
4899 t4 = time.time()
4900 scc_result = []
4901 meta_tuples = {}
4902 for id in stale:
4903 meta_tuple = graph[id].write_cache()
4904 meta_tuples[id] = meta_tuple
4905 # Commit data file write immediately to avoid holding shard locks across modules.
4906 if meta_tuple is not None:
4907 manager.commit_module(meta_tuple[1])
4908 for id in stale:
4909 meta_tuple = meta_tuples[id]
4910 if meta_tuple is None:
4911 continue
4912 meta, meta_file = meta_tuple
4913 state = graph[id]
4914 meta.dep_hashes = [
4915 graph[dep].interface_hash
4916 for dep in state.dependencies
4917 if state.priorities.get(dep) != PRI_INDIRECT
4918 ]
4919 write_cache_meta(meta, manager, meta_file)
4920 manager.commit_module(meta_file)

Callers 1

serveFunction · 0.90

Calls 15

maybe_load_depsFunction · 0.85
order_ascc_exFunction · 0.85
setClass · 0.85
write_cache_metaFunction · 0.85
ModuleResultClass · 0.85
verify_dependenciesMethod · 0.80
type_check_first_passMethod · 0.80
type_checkerMethod · 0.80
discardMethod · 0.80
write_cacheMethod · 0.80
commit_moduleMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…