Process the modules in one SCC from source code.
(graph: Graph, ascc: SCC, manager: BuildManager)
| 4759 | |
| 4760 | |
| 4761 | def process_stale_scc(graph: Graph, ascc: SCC, manager: BuildManager) -> None: |
| 4762 | """Process the modules in one SCC from source code.""" |
| 4763 | # First verify if all transitive dependencies are loaded in the current process. |
| 4764 | t0 = time.time() |
| 4765 | maybe_load_deps(graph, ascc, manager) |
| 4766 | t1 = time.time() |
| 4767 | # Process the SCC in stable order. |
| 4768 | scc = order_ascc_ex(graph, ascc) |
| 4769 | |
| 4770 | t2 = time.time() |
| 4771 | stale = scc |
| 4772 | # Parse before verify_dependencies so that inline config comments |
| 4773 | # (e.g. "# mypy: disable-error-code") are applied to options. |
| 4774 | manager.parse_all([graph[id] for id in stale], post_parse=False) |
| 4775 | for id in stale: |
| 4776 | # Re-generate import errors in case this module was loaded from the cache. |
| 4777 | if graph[id].meta: |
| 4778 | graph[id].verify_dependencies(suppressed_only=True) |
| 4779 | if "typing" in scc: |
| 4780 | # For historical reasons we need to manually add typing aliases |
| 4781 | # for built-in generic collections, see docstring of |
| 4782 | # SemanticAnalyzerPass2.add_builtin_aliases for details. |
| 4783 | typing_mod = graph["typing"].tree |
| 4784 | assert typing_mod, "The typing module was not parsed" |
| 4785 | mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors) |
| 4786 | |
| 4787 | t3 = time.time() |
| 4788 | # Track what modules aren't yet done, so we can finish them as soon |
| 4789 | # as possible, saving memory. |
| 4790 | unfinished_modules = set(stale) |
| 4791 | for id in stale: |
| 4792 | graph[id].type_check_first_pass() |
| 4793 | if not graph[id].type_checker().deferred_nodes: |
| 4794 | unfinished_modules.discard(id) |
| 4795 | graph[id].detect_possibly_undefined_vars() |
| 4796 | graph[id].finish_passes() |
| 4797 | |
| 4798 | while unfinished_modules: |
| 4799 | for id in stale: |
| 4800 | if id not in unfinished_modules: |
| 4801 | continue |
| 4802 | if not graph[id].type_check_second_pass(): |
| 4803 | unfinished_modules.discard(id) |
| 4804 | graph[id].detect_possibly_undefined_vars() |
| 4805 | graph[id].finish_passes() |
| 4806 | for id in stale: |
| 4807 | graph[id].generate_unused_ignore_notes() |
| 4808 | graph[id].generate_ignore_without_code_notes() |
| 4809 | |
| 4810 | t4 = time.time() |
| 4811 | # Flush errors, and write cache in two phases: first data files, then meta files. |
| 4812 | # The two-phase structure is needed because meta.dep_hashes references interface_hash |
| 4813 | # values from other modules in the SCC, which are updated by write_cache(). |
| 4814 | meta_tuples = {} |
| 4815 | errors_by_id = {} |
| 4816 | for id in stale: |
| 4817 | if graph[id].xpath not in manager.errors.ignored_files: |
| 4818 | errors = manager.errors.file_messages(graph[id].xpath) |
no test coverage detected
searching dependent graphs…