Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error reporting on cached run after uninstallation of third party library #17420

Merged
merged 4 commits into from
Jun 22, 2024
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
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
Loading