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 authored Jun 22, 2024
1 parent de4e9d6 commit cc3492e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
7 changes: 5 additions & 2 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3467,8 +3467,11 @@ 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:
errors = manager.errors.file_messages(graph[id].xpath, formatter=manager.error_formatter)
manager.flush_errors(manager.errors.simplify_path(graph[id].xpath), errors, False)
if graph[id].xpath not in manager.errors.ignored_files:
errors = manager.errors.file_messages(
graph[id].xpath, formatter=manager.error_formatter
)
manager.flush_errors(manager.errors.simplify_path(graph[id].xpath), errors, 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 @@ -803,7 +803,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 cc3492e

Please sign in to comment.