Skip to content

Commit

Permalink
Record ignored errors from non-ignored files
Browse files Browse the repository at this point in the history
Before this change, fine-grained builds could spuriously mark ignored
legitimate errors as "unused ignores".

By keeping track of these ignored errors we ensure that enough analysis
is done to know that the ignored lines are actually useful.

We have to change is_errors_for_file so that we don't consider files as
faulty when all of their errors were hidden.
  • Loading branch information
meshy committed Oct 22, 2023
1 parent cca70fc commit b69fe5d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mypy/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,9 @@ def add_error_info(self, info: ErrorInfo) -> None:
self.used_ignored_lines[file][scope_line].append(
(info.code or codes.MISC).code
)
if file not in self.ignored_files:
info.hidden = True
self._add_error_info(file, info)
return
if file in self.ignored_files:
return
Expand Down Expand Up @@ -804,8 +807,9 @@ def blocker_module(self) -> str | None:
return 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
"""Are there any visible errors for the given file?"""
errors = self.error_info_map.get(file, [])
return any(error.hidden is False for error in errors)

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

0 comments on commit b69fe5d

Please sign in to comment.