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

Function invert_deps

mypy/build.py:1669–1692  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1667
1668
1669def 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
1695def generate_deps_for_cache(manager: BuildManager, graph: Graph) -> dict[str, dict[str, set[str]]]:

Callers 1

generate_deps_for_cacheFunction · 0.85

Calls 6

module_prefixFunction · 0.90
trigger_to_targetFunction · 0.90
setClass · 0.85
setdefaultMethod · 0.80
itemsMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…