Skip to content

Commit ba25bd9

Browse files
committed
simplified ignored error checking
1 parent 9d0b73d commit ba25bd9

2 files changed

Lines changed: 1 addition & 19 deletions

File tree

mypy/errors.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -828,24 +828,6 @@ def is_ignored_error(self, line: int, info: ErrorInfo, ignores: dict[int, list[s
828828
)
829829
return False
830830

831-
def is_ignored_error_code(self, line: int, code: ErrorCode) -> bool:
832-
"""Check if an error with the given code on the given line would be ignored.
833-
834-
This is useful to skip expensive error message processing (e.g. fuzzy matching)
835-
when the error will be suppressed anyway.
836-
"""
837-
ignores = self.ignored_lines.get(self.file, {})
838-
if line not in ignores:
839-
return False
840-
if not ignores[line]:
841-
# Empty list means that we ignore all errors
842-
return True
843-
return (
844-
code.code in ignores[line]
845-
or code.sub_code_of is not None
846-
and code.sub_code_of.code in ignores[line]
847-
)
848-
849831
def is_error_code_enabled(self, error_code: ErrorCode) -> bool:
850832
if self.options:
851833
current_mod_disabled = self.options.disabled_error_codes

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7480,7 +7480,7 @@ def name_not_defined(self, name: str, ctx: Context, namespace: str | None = None
74807480
and "." not in name
74817481
and not (name.startswith("__") and name.endswith("__"))
74827482
and f"builtins.{name}" not in SUGGESTED_TEST_FIXTURES
7483-
and not self.errors.is_ignored_error_code(ctx.line, codes.NAME_DEFINED)
7483+
and ctx.line not in self.errors.ignored_lines.get(self.errors.file, {})
74847484
):
74857485
alternatives = self._get_names_in_scope()
74867486
alternatives.discard(name)

0 commit comments

Comments
 (0)