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

Function dump_graph

mypy/build.py:4215–4251  ·  view source on GitHub ↗

Dump the graph as a JSON string to stdout. This copies some of the work by process_graph() (sorted_components() and order_ascc()).

(graph: Graph, stdout: TextIO | None = None)

Source from the content-addressed store, hash-verified

4213
4214
4215def dump_graph(graph: Graph, stdout: TextIO | None = None) -> None:
4216 """Dump the graph as a JSON string to stdout.
4217
4218 This copies some of the work by process_graph()
4219 (sorted_components() and order_ascc()).
4220 """
4221 stdout = stdout or sys.stdout
4222 nodes = []
4223 sccs = sorted_components(graph)
4224 for i, ascc in enumerate(sccs):
4225 scc = order_ascc(graph, ascc.mod_ids)
4226 node = NodeInfo(i, scc)
4227 nodes.append(node)
4228 inv_nodes = {} # module -> node_id
4229 for node in nodes:
4230 for mod in node.scc:
4231 inv_nodes[mod] = node.node_id
4232 for node in nodes:
4233 for mod in node.scc:
4234 state = graph[mod]
4235 size = 0
4236 if state.path:
4237 try:
4238 size = os.path.getsize(state.path)
4239 except OSError:
4240 pass
4241 node.sizes[mod] = size
4242 for dep in state.dependencies:
4243 if dep in state.priorities:
4244 pri = state.priorities[dep]
4245 if dep in inv_nodes:
4246 dep_id = inv_nodes[dep]
4247 if dep_id != node.node_id and (
4248 dep_id not in node.deps or pri < node.deps[dep_id]
4249 ):
4250 node.deps[dep_id] = pri
4251 print("[" + ",\n ".join(node.dumps() for node in nodes) + "\n]", file=stdout)
4252
4253
4254def load_graph(

Callers 1

dispatchFunction · 0.85

Calls 8

dumpsMethod · 0.95
sorted_componentsFunction · 0.85
enumerateFunction · 0.85
order_asccFunction · 0.85
NodeInfoClass · 0.85
printFunction · 0.85
appendMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…