Process implementations (top-level function/method bodies) in an SCC.
(
graph: Graph, stale: list[str], manager: BuildManager, meta_files: list[str]
)
| 4931 | |
| 4932 | |
| 4933 | def process_stale_scc_implementation( |
| 4934 | graph: Graph, stale: list[str], manager: BuildManager, meta_files: list[str] |
| 4935 | ) -> dict[str, ModuleResult]: |
| 4936 | """Process implementations (top-level function/method bodies) in an SCC.""" |
| 4937 | t0 = time.time() |
| 4938 | unfinished_modules = set(stale) |
| 4939 | for id in stale: |
| 4940 | checker = graph[id].type_checker() |
| 4941 | # Optimization: if this is a 3rd party library, or we ignore errors |
| 4942 | # otherwise in this module, skip the implementations altogether. |
| 4943 | if checker.can_skip_diagnostics and not checker.options.preserve_asts: |
| 4944 | unfinished_modules.discard(id) |
| 4945 | graph[id].finish_passes() |
| 4946 | continue |
| 4947 | # We need to reset deferral count after possibly deferring any methods that |
| 4948 | # are considered part of the top-level (because they define/infer variables). |
| 4949 | checker.pass_num = 0 |
| 4950 | checker.deferred_nodes.clear() |
| 4951 | tree = graph[id].tree |
| 4952 | assert tree is not None |
| 4953 | todo = [] |
| 4954 | # Passing impl_only will select only "leaf" nodes (not the TypeInfos). |
| 4955 | for _, node, info in tree.local_definitions(impl_only=True): |
| 4956 | assert isinstance(node.node, (FuncDef, OverloadedFuncDef, Decorator)) |
| 4957 | todo.append(DeferredNode(node.node, info)) |
| 4958 | graph[id].type_check_second_pass(todo=todo, impl_only=True) |
| 4959 | if not checker.deferred_nodes: |
| 4960 | unfinished_modules.discard(id) |
| 4961 | graph[id].detect_possibly_undefined_vars() |
| 4962 | graph[id].finish_passes() |
| 4963 | while unfinished_modules: |
| 4964 | for id in stale: |
| 4965 | if id not in unfinished_modules: |
| 4966 | continue |
| 4967 | if not graph[id].type_check_second_pass(impl_only=True): |
| 4968 | unfinished_modules.discard(id) |
| 4969 | graph[id].detect_possibly_undefined_vars() |
| 4970 | graph[id].finish_passes() |
| 4971 | |
| 4972 | for id in stale: |
| 4973 | graph[id].generate_unused_ignore_notes() |
| 4974 | graph[id].generate_ignore_without_code_notes() |
| 4975 | |
| 4976 | scc_result = {} |
| 4977 | for id, meta_file in zip(stale, meta_files): |
| 4978 | state = graph[id] |
| 4979 | indirect = [dep for dep in state.dependencies if state.priorities.get(dep) == PRI_INDIRECT] |
| 4980 | meta_ex = CacheMetaEx( |
| 4981 | dependencies=indirect, |
| 4982 | suppressed=[ |
| 4983 | dep for dep in state.suppressed if state.priorities.get(dep) == PRI_INDIRECT |
| 4984 | ], |
| 4985 | dep_hashes=[graph[dep].interface_hash for dep in indirect], |
| 4986 | error_lines=[], |
| 4987 | ) |
| 4988 | if graph[id].xpath not in manager.errors.ignored_files: |
| 4989 | errors = manager.errors.file_messages(graph[id].xpath) |
| 4990 | formatted = manager.errors.format_messages( |
no test coverage detected
searching dependent graphs…