Splits fine-grained dependencies based on the module of the trigger. Returns a dictionary from module ids to all dependencies on that module. Dependencies not associated with a module in the build will be associated with the nearest parent module that is in the build, or the fake mo
(deps: dict[str, set[str]], graph: Graph)
| 1667 | |
| 1668 | |
| 1669 | def invert_deps(deps: dict[str, set[str]], graph: Graph) -> dict[str, dict[str, set[str]]]: |
| 1670 | """Splits fine-grained dependencies based on the module of the trigger. |
| 1671 | |
| 1672 | Returns a dictionary from module ids to all dependencies on that |
| 1673 | module. Dependencies not associated with a module in the build will be |
| 1674 | associated with the nearest parent module that is in the build, or the |
| 1675 | fake module FAKE_ROOT_MODULE if none are. |
| 1676 | """ |
| 1677 | # Lazy import to speed up startup |
| 1678 | from mypy.server.target import trigger_to_target |
| 1679 | |
| 1680 | # Prepopulate the map for all the modules that have been processed, |
| 1681 | # so that we always generate files for processed modules (even if |
| 1682 | # there aren't any dependencies to them.) |
| 1683 | rdeps: dict[str, dict[str, set[str]]] = {id: {} for id, st in graph.items() if st.tree} |
| 1684 | for trigger, targets in deps.items(): |
| 1685 | module = module_prefix(graph, trigger_to_target(trigger)) |
| 1686 | if not module or not graph[module].tree: |
| 1687 | module = FAKE_ROOT_MODULE |
| 1688 | |
| 1689 | mod_rdeps = rdeps.setdefault(module, {}) |
| 1690 | mod_rdeps.setdefault(trigger, set()).update(targets) |
| 1691 | |
| 1692 | return rdeps |
| 1693 | |
| 1694 | |
| 1695 | def generate_deps_for_cache(manager: BuildManager, graph: Graph) -> dict[str, dict[str, set[str]]]: |
no test coverage detected
searching dependent graphs…