Debian Codegraph @

mypyc/errors.py

raw
1 from __future__ import annotations
2
3 import mypy.errors
4 from mypy.options import Options
5
6
7 class Errors:
8 def __init__(self, options: Options) -> None:
9 self.num_errors = 0
10 self.num_warnings = 0
11 self._errors = mypy.errors.Errors(options, hide_error_codes=True)
12
13 def error(self, msg: str, path: str, line: int) -> None:
14 self._errors.set_file(path, None, self._errors.options)
15 self._errors.report(line, None, msg, severity="error")
16 self.num_errors += 1
17
18 def note(self, msg: str, path: str, line: int) -> None:
19 self._errors.set_file(path, None, self._errors.options)
20 self._errors.report(line, None, msg, severity="note")
21
22 def warning(self, msg: str, path: str, line: int) -> None:
23 self._errors.set_file(path, None, self._errors.options)
24 self._errors.report(line, None, msg, severity="warning")
25 self.num_warnings += 1
26
27 def new_messages(self) -> list[str]:
28 return self._errors.new_messages()
29
30 def flush_errors(self) -> None:
31 for error in self.new_messages():
32 print(error)