Skip to content

Commit 6d9890e

Browse files
committed
Update code to use topsort2
1 parent c9d2e1b commit 6d9890e

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

mypy/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
ErrorTupleRaw,
9595
report_internal_error,
9696
)
97-
from mypy.graph_utils import prepare_sccs, strongly_connected_components, topsort
97+
from mypy.graph_utils import prepare_sccs, strongly_connected_components, topsort2
9898
from mypy.indirection import TypeIndirectionVisitor
9999
from mypy.ipc import BadStatus, IPCClient, IPCMessage, read_status, ready_to_read, receive, send
100100
from mypy.messages import MessageBuilder
@@ -4236,7 +4236,7 @@ def sorted_components(graph: Graph) -> list[SCC]:
42364236
scc_dep_map = prepare_sccs_full(strongly_connected_components(vertices, edges), edges)
42374237
# Topsort.
42384238
res = []
4239-
for ready in topsort(scc_dep_map):
4239+
for ready in topsort2(scc_dep_map):
42404240
# Sort the sets in ready by reversed smallest State.order. Examples:
42414241
#
42424242
# - If ready is [{x}, {y}], x.order == 1, y.order == 2, we get
@@ -4271,7 +4271,7 @@ def sorted_components_inner(
42714271
edges = {id: deps_filtered(graph, vertices, id, pri_max) for id in vertices}
42724272
sccs = list(strongly_connected_components(vertices, edges))
42734273
res = []
4274-
for ready in topsort(prepare_sccs(sccs, edges)):
4274+
for ready in topsort2(prepare_sccs(sccs, edges)):
42754275
res.extend(sorted(ready, key=lambda scc: -min(graph[id].order for id in scc)))
42764276
return res
42774277

mypy/graph_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def topsort(data: dict[T, set[T]]) -> Iterable[set[T]]:
117117
assert not data, f"A cyclic dependency exists amongst {data!r}"
118118

119119

120-
class topsort2(Iterator[set[T]]):
120+
class topsort2(Iterator[set[T]]): # noqa: N801
121121
"""Topological sort using Kahn's algorithm.
122122
123123
This is functionally equivalent to topsort() but avoids rebuilding

mypy/solve.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from mypy.constraints import SUBTYPE_OF, SUPERTYPE_OF, Constraint, infer_constraints, neg_op
1010
from mypy.expandtype import expand_type
11-
from mypy.graph_utils import prepare_sccs, strongly_connected_components, topsort
11+
from mypy.graph_utils import prepare_sccs, strongly_connected_components, topsort2
1212
from mypy.join import join_type_list
1313
from mypy.meet import meet_type_list, meet_types
1414
from mypy.subtypes import is_subtype
@@ -147,7 +147,7 @@ def solve_with_dependent(
147147
sccs = list(strongly_connected_components(set(vars), dmap))
148148
if not all(check_linear(scc, lowers, uppers) for scc in sccs):
149149
return {}, []
150-
raw_batches = list(topsort(prepare_sccs(sccs, dmap)))
150+
raw_batches = list(topsort2(prepare_sccs(sccs, dmap)))
151151

152152
free_vars = []
153153
free_solutions = {}

0 commit comments

Comments
 (0)