You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
runtime flag to disable all # type: ignore comments #19476
I thought this might be supported, but could not find it in the docs or --help. I also couldn't find this request as a closed or open issue; apologies if this has been discussed.
I believe it would be beneficial for mypy to have a --disable-ignores flag or similar.
The flag would simply ignore all code decorated with # type: ignore* or similar.
Pitch
This would simplify auditing and managing legacy code.
Often times, errors are suppressed because mypy does not yet have a relevant feature or the developer's codebase requires too much refactoring. This is somewhat similar to the current support for unused ignores, but would help developers catch situations where slight edits to code might make it conformant to mypy.
Periodically disable all ignores for an audit is an important part of maintaining code health. Bringing this functionality into mypy would be much easier than running mypy on a version of the code with the ignores stripped.
You have my +1 for this feature, it's something I wanted to use myself when looking at a legacy codebase with ignore comments placed randomly, mostly in places where mypy diagnostics were correct. This should be easy to implement. (but the documentation must be crystal clear that this flag is not supposed to be enabled in long run and should only be used locally to find existing defects)
To handle it myself, I just gradually removed all the ignores in a file/module with a simple find -exec sed command, fixed typing and added the correct ones back. Going through all files this way wasn't much slower than toggling such mypy flag, so probably this is a low-prio feature.
Activity
sterliakov commentedon Jul 17, 2025
You have my +1 for this feature, it's something I wanted to use myself when looking at a legacy codebase with ignore comments placed randomly, mostly in places where mypy diagnostics were correct. This should be easy to implement. (but the documentation must be crystal clear that this flag is not supposed to be enabled in long run and should only be used locally to find existing defects)
To handle it myself, I just gradually removed all the ignores in a file/module with a simple
find -exec sedcommand, fixed typing and added the correct ones back. Going through all files this way wasn't much slower than toggling such mypy flag, so probably this is a low-prio feature.brianschubert commentedon Jul 17, 2025
Duplicate of #13201?
jvanasco commentedon Jul 17, 2025
Yes. Feel free to close this. Sorry, I did not find that - searching "ignore ignore" and "disable ignore" came up with pages of unrelated issues.
sterliakov commentedon Jul 17, 2025
Thanks! I also failed to find that dupe, and it didn't have proper topic labels either.
type: ignore, disabled error codes #13201