diff --git a/mypy/errors.py b/mypy/errors.py index 9d29259e943c..b230b3baa3f6 100644 --- a/mypy/errors.py +++ b/mypy/errors.py @@ -90,6 +90,7 @@ class ErrorInfo: def __init__( self, import_ctx: list[tuple[str, int]], + *, file: str, module: str | None, typ: str | None, @@ -415,21 +416,21 @@ def report( code = code or (codes.MISC if not blocker else None) info = ErrorInfo( - self.import_context(), - file, - self.current_module(), - type, - function, - line, - column, - end_line, - end_column, - severity, - message, - code, - blocker, - only_once, - allow_dups, + import_ctx=self.import_context(), + file=file, + module=self.current_module(), + typ=type, + function_or_member=function, + line=line, + column=column, + end_line=end_line, + end_column=end_column, + severity=severity, + message=message, + code=code, + blocker=blocker, + only_once=only_once, + allow_dups=allow_dups, origin=(self.file, origin_span), target=self.current_target(), ) @@ -511,17 +512,17 @@ def add_error_info(self, info: ErrorInfo) -> None: + "may be out of date" ) note = ErrorInfo( - info.import_ctx, - info.file, - info.module, - info.type, - info.function_or_member, - info.line, - info.column, - info.end_line, - info.end_column, - "note", - msg, + import_ctx=info.import_ctx, + file=info.file, + module=info.module, + typ=info.type, + function_or_member=info.function_or_member, + line=info.line, + column=info.column, + end_line=info.end_line, + end_column=info.end_column, + severity="note", + message=msg, code=None, blocker=False, only_once=False, @@ -653,21 +654,21 @@ def generate_unused_ignore_errors(self, file: str) -> None: message += f", use narrower [{', '.join(narrower)}] instead of [{unused}] code" # Don't use report since add_error_info will ignore the error! info = ErrorInfo( - self.import_context(), - file, - self.current_module(), - None, - None, - line, - -1, - line, - -1, - "error", - message, - codes.UNUSED_IGNORE, - False, - False, - False, + import_ctx=self.import_context(), + file=file, + module=self.current_module(), + typ=None, + function_or_member=None, + line=line, + column=-1, + end_line=line, + end_column=-1, + severity="error", + message=message, + code=codes.UNUSED_IGNORE, + blocker=False, + only_once=False, + allow_dups=False, ) self._add_error_info(file, info) @@ -705,21 +706,21 @@ def generate_ignore_without_code_errors( message = f'"type: ignore" comment without error code{codes_hint}' # Don't use report since add_error_info will ignore the error! info = ErrorInfo( - self.import_context(), - file, - self.current_module(), - None, - None, - line, - -1, - line, - -1, - "error", - message, - codes.IGNORE_WITHOUT_CODE, - False, - False, - False, + import_ctx=self.import_context(), + file=file, + module=self.current_module(), + typ=None, + function_or_member=None, + line=line, + column=-1, + end_line=line, + end_column=-1, + severity="error", + message=message, + code=codes.IGNORE_WITHOUT_CODE, + blocker=False, + only_once=False, + allow_dups=False, ) self._add_error_info(file, info)