MCPcopy Index your code
hub / github.com/python/mypy / format_messages

Method format_messages

mypy/errors.py:1090–1111  ·  view source on GitHub ↗

Return a string list of new error messages from a given file. Use a form suitable for displaying to the user.

(
        self, path: str, error_tuples: list[ErrorTuple], formatter: ErrorFormatter | None = None
    )

Source from the content-addressed store, hash-verified

1088 return self.render_messages(path, error_info)
1089
1090 def format_messages(
1091 self, path: str, error_tuples: list[ErrorTuple], formatter: ErrorFormatter | None = None
1092 ) -> list[str]:
1093 """Return a string list of new error messages from a given file.
1094
1095 Use a form suitable for displaying to the user.
1096 """
1097 self.flushed_files.add(path)
1098 if formatter is not None:
1099 errors = create_errors(error_tuples)
1100 return [formatter.report_error(err) for err in errors]
1101
1102 source_lines = None
1103 if self.options.pretty and self.read_source:
1104 # Find shadow file mapping and read source lines if a shadow file exists for the given path.
1105 # If shadow file mapping is not found, read source lines
1106 mapped_path = self.find_shadow_file_mapping(path)
1107 if mapped_path:
1108 source_lines = self.read_source(mapped_path)
1109 else:
1110 source_lines = self.read_source(path)
1111 return self.format_messages_default(error_tuples, source_lines)
1112
1113 def find_shadow_file_mapping(self, path: str) -> str | None:
1114 """Return the shadow file path for a given source file path or None."""

Callers 4

new_messagesMethod · 0.95
find_stale_sccsFunction · 0.80
process_stale_sccFunction · 0.80

Calls 5

create_errorsFunction · 0.85
addMethod · 0.45
report_errorMethod · 0.45

Tested by

no test coverage detected