Skip to content

Commit fd8a15e

Browse files
authored
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 efe9a31 commit fd8a15e

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
@@ -2965,12 +2965,16 @@ def process_graph(graph: Graph, manager: BuildManager) -> None:
29652965
# Order the SCC's nodes using a heuristic.
29662966
# Note that ascc is a set, and scc is a list.
29672967
scc = order_ascc(graph, ascc)
2968-
# If builtins is in the list, move it last. (This is a bit of
2969-
# a hack, but it's necessary because the builtins module is
2970-
# part of a small cycle involving at least {builtins, abc,
2971-
# typing}. Of these, builtins must be processed last or else
2972-
# some builtin objects will be incompletely processed.)
2968+
# Make the order of the SCC that includes 'builtins' and 'typing',
2969+
# among other things, predictable. Various things may break if
2970+
# the order changes.
29732971
if 'builtins' in ascc:
2972+
scc = sorted(scc, reverse=True)
2973+
# If builtins is in the list, move it last. (This is a bit of
2974+
# a hack, but it's necessary because the builtins module is
2975+
# part of a small cycle involving at least {builtins, abc,
2976+
# typing}. Of these, builtins must be processed last or else
2977+
# some builtin objects will be incompletely processed.)
29742978
scc.remove('builtins')
29752979
scc.append('builtins')
29762980
if manager.options.verbosity >= 2:

0 commit comments

Comments
 (0)