Skip to content

runtime flag to disable all # type: ignore comments #19476

Description

@jvanasco

Feature

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.

Activity

  1. sterliakov commented on Jul 17, 2025

    @sterliakov
    Collaborator

    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.

  2. brianschubert commented on Jul 17, 2025

    @brianschubert
    Collaborator

    Duplicate of #13201?

  3. jvanasco commented on Jul 17, 2025

    @jvanasco
    Author

    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.

  4. sterliakov commented on Jul 17, 2025

    @sterliakov
    Collaborator

    Thanks! I also failed to find that dupe, and it didn't have proper topic labels either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions