Skip to content

Commit

Permalink
Fix error reporting on cached run after uninstallation of third party…
Browse files Browse the repository at this point in the history
… library (python#17420)

Fixes python#16766, fixes
python#17049
  • Loading branch information
hauntsaninja committed Jun 22, 2024
1 parent 0209270 commit cfbe004
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
11 changes: 6 additions & 5 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3459,11 +3459,12 @@ def process_stale_scc(graph: Graph, scc: list[str], manager: BuildManager) -> No
for id in stale:
graph[id].transitive_error = True
for id in stale:
manager.flush_errors(
manager.errors.simplify_path(graph[id].xpath),
manager.errors.file_messages(graph[id].xpath),
False,
)
if graph[id].xpath not in manager.errors.ignored_files:
manager.flush_errors(
manager.errors.simplify_path(graph[id].xpath),
manager.errors.file_messages(graph[id].xpath),
False,
)
graph[id].write_cache()
graph[id].mark_as_rechecked()

Expand Down
2 changes: 1 addition & 1 deletion mypy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def blocker_module(self) -> str | None:

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

def prefer_simple_messages(self) -> bool:
"""Should we generate simple/fast error messages?
Expand Down
15 changes: 15 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,21 @@ main:3: note: Revealed type is "builtins.int"
main:3: note: Revealed type is "Any"


[case testIncrementalIgnoreErrors]
# flags: --config-file tmp/mypy.ini
import a
[file a.py]
import module_that_will_be_deleted
[file module_that_will_be_deleted.py]

[file mypy.ini]
\[mypy]
\[mypy-a]
ignore_errors = True
[delete module_that_will_be_deleted.py.2]
[out1]
[out2]

[case testIncrementalNamedTupleInMethod]
from ntcrash import nope
[file ntcrash.py]
Expand Down

0 comments on commit cfbe004

Please sign in to comment.