Error codes

Mypy can optionally display an error code such as [attr-defined]after each error message. Error codes serve two purposes:

  • It’s possible to silence specific error codes on a line using # type: ignore[code]. This way you won’t accidentally ignore other,potentially more serious errors.
  • The error code can be used to find documentation about the error.The next two topics (Error codes enabled by default andError codes for optional checks) document the various error codesmypy can report. Most error codes are shared between multiple related error messages.Error codes may change in future mypy releases.