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

Method on_error

mypy/errors.py:241–264  ·  view source on GitHub ↗

Handler called when a new error is recorded. The default implementation just sets the has_new_errors flag Return True to filter out the error, preventing it from being seen by other ErrorWatcher further down the stack and from being recorded by Errors

(self, file: str, info: ErrorInfo)

Source from the content-addressed store, hash-verified

239 return False
240
241 def on_error(self, file: str, info: ErrorInfo) -> bool:
242 """Handler called when a new error is recorded.
243
244 The default implementation just sets the has_new_errors flag
245
246 Return True to filter out the error, preventing it from being seen by other
247 ErrorWatcher further down the stack and from being recorded by Errors
248 """
249 if info.code == codes.DEPRECATED:
250 # Deprecated is not a type error, so it is handled on opt-in basis here.
251 if not self._filter_deprecated:
252 return False
253
254 self._has_new_errors = True
255 if isinstance(self._filter, bool):
256 should_filter = self._filter
257 elif callable(self._filter):
258 should_filter = self._filter(file, info)
259 else:
260 raise AssertionError(f"invalid error filter: {type(self._filter)}")
261 if should_filter and self._filtered is not None:
262 self._filtered.append(info)
263
264 return should_filter
265
266 def has_new_errors(self) -> bool:
267 return self._has_new_errors

Callers 2

on_errorMethod · 0.45
_filter_errorMethod · 0.45

Calls 3

isinstanceFunction · 0.85
typeClass · 0.85
appendMethod · 0.80

Tested by

no test coverage detected