Skip to content

Commit 367b29d

Browse files
committed
Make order of processing the builtins SCC predictable (#12431)
Various things can go wrong if the order of modules in the builtins SCC that also includes typing, _typeshed and others is adjusted. Hopefully fixes #12422. May also fix #12421.
1 parent f81b228 commit 367b29d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

mypy/build.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -2959,12 +2959,16 @@ def process_graph(graph: Graph, manager: BuildManager) -> None:
29592959
# Order the SCC's nodes using a heuristic.
29602960
# Note that ascc is a set, and scc is a list.
29612961
scc = order_ascc(graph, ascc)
2962-
# If builtins is in the list, move it last. (This is a bit of
2963-
# a hack, but it's necessary because the builtins module is
2964-
# part of a small cycle involving at least {builtins, abc,
2965-
# typing}. Of these, builtins must be processed last or else
2966-
# some builtin objects will be incompletely processed.)
2962+
# Make the order of the SCC that includes 'builtins' and 'typing',
2963+
# among other things, predictable. Various things may break if
2964+
# the order changes.
29672965
if 'builtins' in ascc:
2966+
scc = sorted(scc, reverse=True)
2967+
# If builtins is in the list, move it last. (This is a bit of
2968+
# a hack, but it's necessary because the builtins module is
2969+
# part of a small cycle involving at least {builtins, abc,
2970+
# typing}. Of these, builtins must be processed last or else
2971+
# some builtin objects will be incompletely processed.)
29682972
scc.remove('builtins')
29692973
scc.append('builtins')
29702974
if manager.options.verbosity >= 2:

0 commit comments

Comments
 (0)