Skip to content

Commit

Permalink
Make order of processing the builtins SCC predictable (#12431)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JukkaL committed Mar 23, 2022
1 parent f81b228 commit 367b29d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2959,12 +2959,16 @@ def process_graph(graph: Graph, manager: BuildManager) -> None:
# Order the SCC's nodes using a heuristic.
# Note that ascc is a set, and scc is a list.
scc = order_ascc(graph, ascc)
# If builtins is in the list, move it last. (This is a bit of
# a hack, but it's necessary because the builtins module is
# part of a small cycle involving at least {builtins, abc,
# typing}. Of these, builtins must be processed last or else
# some builtin objects will be incompletely processed.)
# Make the order of the SCC that includes 'builtins' and 'typing',
# among other things, predictable. Various things may break if
# the order changes.
if 'builtins' in ascc:
scc = sorted(scc, reverse=True)
# If builtins is in the list, move it last. (This is a bit of
# a hack, but it's necessary because the builtins module is
# part of a small cycle involving at least {builtins, abc,
# typing}. Of these, builtins must be processed last or else
# some builtin objects will be incompletely processed.)
scc.remove('builtins')
scc.append('builtins')
if manager.options.verbosity >= 2:
Expand Down

0 comments on commit 367b29d

Please sign in to comment.