@davidhalter Invited me to share mypy perspective on this. So here are my 2 cents. I think that apart from plain # type: ignore there is just one (simple) rule that is important to standardize/require to allow different type checkers to cooperate efficiently. If a type checker encounters an ignore like this # type: ignore[one-code, other_code, namespaced:code], then it should:
- Respect only the error codes it recognizes, and
- Do not complain about unknown error codes being used
This means that in example by @jorenham, a comment like
# type: ignore[override, reportIncompatibleMethodOverride, bad-override, invalid-method-override]
will work, i.e. it will silence 4 type checkers and will not let any other error on this line be accidentally ignored.
This is the current behavior of mypy, and it is unlikely to change. Other things (like what to do with “invalid“ type ignores that don’t match the pattern I mentioned above) can be considered an implementation detail and left up to individual type checkers.