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

Function sorted_components_inner

mypy/build.py:5063–5077  ·  view source on GitHub ↗

Simplified version of sorted_components() to work with sub-graphs. This doesn't create SCC objects, and operates with raw sets. This function also allows filtering dependencies to take into account when building SCCs. This is used for heuristic ordering of modules within actual SCCs.

(
    graph: Graph, vertices: AbstractSet[str], pri_max: int
)

Source from the content-addressed store, hash-verified

5061
5062
5063def sorted_components_inner(
5064 graph: Graph, vertices: AbstractSet[str], pri_max: int
5065) -> list[AbstractSet[str]]:
5066 """Simplified version of sorted_components() to work with sub-graphs.
5067
5068 This doesn't create SCC objects, and operates with raw sets. This function
5069 also allows filtering dependencies to take into account when building SCCs.
5070 This is used for heuristic ordering of modules within actual SCCs.
5071 """
5072 edges = {id: deps_filtered(graph, vertices, id, pri_max) for id in vertices}
5073 sccs = list(strongly_connected_components(vertices, edges))
5074 res = []
5075 for ready in topsort(prepare_sccs(sccs, edges)):
5076 res.extend(sorted(ready, key=lambda scc: -min(graph[id].order for id in scc)))
5077 return res
5078
5079
5080def deps_filtered(graph: Graph, vertices: AbstractSet[str], id: str, pri_max: int) -> list[str]:

Callers 1

order_asccFunction · 0.85

Calls 8

topsortClass · 0.90
prepare_sccsFunction · 0.90
deps_filteredFunction · 0.85
listClass · 0.85
sortedFunction · 0.85
minFunction · 0.85
extendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…