Skip to content

Commit cfbe004

Browse files
committed
Fix error reporting on cached run after uninstallation of third party library (python#17420)
Fixes python#16766, fixes python#17049
1 parent 0209270 commit cfbe004

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

mypy/build.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3459,11 +3459,12 @@ def process_stale_scc(graph: Graph, scc: list[str], manager: BuildManager) -> No
34593459
for id in stale:
34603460
graph[id].transitive_error = True
34613461
for id in stale:
3462-
manager.flush_errors(
3463-
manager.errors.simplify_path(graph[id].xpath),
3464-
manager.errors.file_messages(graph[id].xpath),
3465-
False,
3466-
)
3462+
if graph[id].xpath not in manager.errors.ignored_files:
3463+
manager.flush_errors(
3464+
manager.errors.simplify_path(graph[id].xpath),
3465+
manager.errors.file_messages(graph[id].xpath),
3466+
False,
3467+
)
34673468
graph[id].write_cache()
34683469
graph[id].mark_as_rechecked()
34693470

mypy/errors.py

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

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

807807
def prefer_simple_messages(self) -> bool:
808808
"""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)