Skip to content

Commit cc3492e

Browse files
authored
Fix error reporting on cached run after uninstallation of third party library (#17420)
Fixes #16766, fixes #17049
1 parent de4e9d6 commit cc3492e

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

mypy/build.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3467,8 +3467,11 @@ def process_stale_scc(graph: Graph, scc: list[str], manager: BuildManager) -> No
34673467
for id in stale:
34683468
graph[id].transitive_error = True
34693469
for id in stale:
3470-
errors = manager.errors.file_messages(graph[id].xpath, formatter=manager.error_formatter)
3471-
manager.flush_errors(manager.errors.simplify_path(graph[id].xpath), errors, False)
3470+
if graph[id].xpath not in manager.errors.ignored_files:
3471+
errors = manager.errors.file_messages(
3472+
graph[id].xpath, formatter=manager.error_formatter
3473+
)
3474+
manager.flush_errors(manager.errors.simplify_path(graph[id].xpath), errors, False)
34723475
graph[id].write_cache()
34733476
graph[id].mark_as_rechecked()
34743477

mypy/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ def blocker_module(self) -> str | None:
803803

804804
def is_errors_for_file(self, file: str) -> bool:
805805
"""Are there any errors for the given file?"""
806-
return file in self.error_info_map
806+
return file in self.error_info_map and file not in self.ignored_files
807807

808808
def prefer_simple_messages(self) -> bool:
809809
"""Should we generate simple/fast error messages?

test-data/unit/check-incremental.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,6 +1833,21 @@ main:3: note: Revealed type is "builtins.int"
18331833
main:3: note: Revealed type is "Any"
18341834

18351835

1836+
[case testIncrementalIgnoreErrors]
1837+
# flags: --config-file tmp/mypy.ini
1838+
import a
1839+
[file a.py]
1840+
import module_that_will_be_deleted
1841+
[file module_that_will_be_deleted.py]
1842+
1843+
[file mypy.ini]
1844+
\[mypy]
1845+
\[mypy-a]
1846+
ignore_errors = True
1847+
[delete module_that_will_be_deleted.py.2]
1848+
[out1]
1849+
[out2]
1850+
18361851
[case testIncrementalNamedTupleInMethod]
18371852
from ntcrash import nope
18381853
[file ntcrash.py]

0 commit comments

Comments
 (0)