Skip to content

Commit 84271b0

Browse files
committed
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 cca70fc commit 84271b0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mypy/errors.py

+6-2
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
@@ -804,8 +807,9 @@ def blocker_module(self) -> str | None:
804807
return None
805808

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

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

0 commit comments

Comments
 (0)