From 99b13580a3de3ec6602f9374cb6ed7aeaf9f2cb6 Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Mon, 22 Sep 2025 16:08:56 +0100 Subject: [PATCH] Don't consider indirect dependencies when calculating SCCs SCC construction should only consider import dependencies, since indirect dependencies are not available during non-incremental runs. I think otherwise SCCs can be different in non-incremental vs incremtal runs. Attempt to fix an issue with excessively large SCCs computed (sometimes) after #19798 when doing incremental runs. I haven't been able to create a self-contained test case that reproduces the issue, but this appears to fix this issue with an internal codebase. --- mypy/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/build.py b/mypy/build.py index 2d3296a4713e..ad25b811ff7c 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -3488,7 +3488,7 @@ def process_stale_scc(graph: Graph, scc: list[str], manager: BuildManager) -> No def sorted_components( - graph: Graph, vertices: AbstractSet[str] | None = None, pri_max: int = PRI_ALL + graph: Graph, vertices: AbstractSet[str] | None = None, pri_max: int = PRI_INDIRECT ) -> list[AbstractSet[str]]: """Return the graph's SCCs, topologically sorted by dependencies.