Skip to content

Commit c27e832

Browse files
meshyseddonym
authored andcommitted
Record ignored errors from non-ignored files
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.
1 parent 822f2a9 commit c27e832

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mypy/errors.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ def add_error_info(self, info: ErrorInfo) -> None:
503503
self.used_ignored_lines[file][scope_line].append(
504504
(info.code or codes.MISC).code
505505
)
506+
if file not in self.ignored_files:
507+
info.hidden = True
508+
self._add_error_info(file, info)
506509
return
507510
if file in self.ignored_files:
508511
return
@@ -805,8 +808,9 @@ def blocker_module(self) -> str | None:
805808
return None
806809

807810
def is_errors_for_file(self, file: str) -> bool:
808-
"""Are there any errors for the given file?"""
809-
return file in self.error_info_map
811+
"""Are there any visible errors for the given file?"""
812+
errors = self.error_info_map.get(file, ())
813+
return any(error.hidden is False for error in errors)
810814

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

0 commit comments

Comments
 (0)