Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -4769,13 +4769,13 @@ def process_stale_scc(graph: Graph, ascc: SCC, manager: BuildManager) -> None:

t2 = time.time()
stale = scc
# Parse before verify_dependencies so that inline config comments
# (e.g. "# mypy: disable-error-code") are applied to options.
manager.parse_all([graph[id] for id in stale], post_parse=False)
for id in stale:
# Re-generate import errors in case this module was loaded from the cache.
if graph[id].meta:
graph[id].verify_dependencies(suppressed_only=True)
# We may already have parsed the modules, or not.
# If the former, parse_file() is a no-op.
manager.parse_all([graph[id] for id in stale], post_parse=False)
if "typing" in scc:
# For historical reasons we need to manually add typing aliases
# for built-in generic collections, see docstring of
Expand Down
16 changes: 16 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -7995,3 +7995,19 @@ import mod
[out2]
main:2: error: Cannot find implementation or library stub for module named "mod"
main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

[case testIncrementalFileConfigCommentsStale]
-- When a dependency changes, the importing module becomes stale and is
-- reprocessed via process_stale_scc. As inline config comments are not cached
-- (by design), moving the order of processing the stale SCC can accidentally
-- break file config comments on subsequent runs.
# mypy: disable-error-code="import-not-found"
import nonexistent
import b
[file b.py]
x = 1
[file b.py.2]
x = "hello"
[builtins fixtures/module.pyi]
[stale b]
[rechecked b]
Loading