Reprocess a set of nodes within a single module. Return fired triggers.
(
manager: BuildManager,
graph: dict[str, State],
module_id: str,
nodeset: set[FineGrainedDeferredNode],
deps: dict[str, set[str]],
processed_targets: list[str],
)
| 960 | |
| 961 | |
| 962 | def reprocess_nodes( |
| 963 | manager: BuildManager, |
| 964 | graph: dict[str, State], |
| 965 | module_id: str, |
| 966 | nodeset: set[FineGrainedDeferredNode], |
| 967 | deps: dict[str, set[str]], |
| 968 | processed_targets: list[str], |
| 969 | ) -> set[str]: |
| 970 | """Reprocess a set of nodes within a single module. |
| 971 | |
| 972 | Return fired triggers. |
| 973 | """ |
| 974 | if module_id not in graph: |
| 975 | manager.log_fine_grained("%s not in graph (blocking errors or deleted?)" % module_id) |
| 976 | return set() |
| 977 | |
| 978 | file_node = manager.modules[module_id] |
| 979 | old_symbols = find_symbol_tables_recursive(file_node.fullname, file_node.names) |
| 980 | old_symbols = {name: names.copy() for name, names in old_symbols.items()} |
| 981 | old_symbols_snapshot = snapshot_symbol_table(file_node.fullname, file_node.names) |
| 982 | |
| 983 | def key(node: FineGrainedDeferredNode) -> int: |
| 984 | # Unlike modules which are sorted by name within SCC, |
| 985 | # nodes within the same module are sorted by line number, because |
| 986 | # this is how they are processed in normal mode. |
| 987 | return node.node.line |
| 988 | |
| 989 | nodes = sorted(nodeset, key=key) |
| 990 | |
| 991 | state = graph[module_id] |
| 992 | options = state.options |
| 993 | manager.errors.set_file_ignored_lines( |
| 994 | file_node.path, file_node.ignored_lines, options.ignore_errors or state.ignore_all |
| 995 | ) |
| 996 | manager.errors.set_skipped_lines(file_node.path, file_node.skipped_lines) |
| 997 | |
| 998 | targets = set() |
| 999 | for node in nodes: |
| 1000 | target = target_from_node(module_id, node.node) |
| 1001 | if target is not None: |
| 1002 | targets.add(target) |
| 1003 | manager.errors.clear_errors_in_targets(file_node.path, targets) |
| 1004 | |
| 1005 | # If one of the nodes is the module itself, emit any errors that |
| 1006 | # happened before semantic analysis. |
| 1007 | for target in targets: |
| 1008 | if target == module_id: |
| 1009 | for info in graph[module_id].early_errors: |
| 1010 | manager.errors.add_error_info(info, file=graph[module_id].xpath) |
| 1011 | |
| 1012 | # Strip semantic analysis information. |
| 1013 | for deferred in nodes: |
| 1014 | processed_targets.append(deferred.node.fullname) |
| 1015 | strip_target(deferred.node) |
| 1016 | semantic_analysis_for_targets(graph[module_id], nodes, graph) |
| 1017 | # Merge symbol tables to preserve identities of AST nodes. The file node will remain |
| 1018 | # the same, but other nodes may have been recreated with different identities, such as |
| 1019 | # NamedTuples defined using assignment statements. |
no test coverage detected
searching dependent graphs…