Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Support for Enabling/Disabling Specific Error Codes similar to Pylint #17722

Closed
nh916 opened this issue Aug 29, 2024 · 1 comment
Labels

Comments

@nh916
Copy link

nh916 commented Aug 29, 2024

Description:

Hello, mypy team, I would like to propose a feature that allows users to enable or disable specific error codes in mypy, similar to the functionality available in tools like pylint.

Use Case

Currently, mypy allows for some configuration through the mypy.ini file, such as ignoring missing imports globally or for specific modules, and suppressing individual lines with # type: ignore. However, there is no way to selectively enable or disable specific error codes within the terminal when working on a specific set of errors.

It would be great if I am can have a command such as mypy . --disable=all --enable=untyped-imports and then only see the imports without stubs errors and slowly make my way through those without being overwhelmed by all other errors.

Proposed Solution

To address this, I suggest adding the ability to enable or disable specific error codes via command-line options. This would allow users to focus on specific issues at a time, making it easier to progressively improve the type annotations in a codebase.

For example, a command like this could be used:

mypy . --disable-error-codes=all --enable-error-codes=untyped-import

This would show only errors related to untyped imports, allowing a developer address errors as they move through a large code base.

Benefits

  • Granular Control: This feature would give developers more control over the type-checking process, allowing them to focus on specific areas of their code that need attention.
  • Improved Workflow: By allowing the progressive resolution of type-checking issues, developers can avoid being overwhelmed by large numbers of errors, making mypy easier to integrate into existing projects.
  • Enhanced Usability: Aligning mypy with tools like pylint in terms of configuration and error handling would make it more intuitive and flexible for developers already familiar with these tools.

Additional Context

This feature could significantly enhance mypy's usability, particularly in large projects where gradually improving type coverage is a priority. It would also facilitate the adoption of mypy in environments where developers may need to focus on specific issues without being distracted by unrelated errors.

Thank you for considering this feature request. I believe it would be a valuable addition to mypy, helping to make Python type checking more manageable for developers.

@nh916 nh916 added the feature label Aug 29, 2024
@emmatyping
Copy link
Collaborator

Mypy already has error codes: https://mypy.readthedocs.io/en/stable/error_codes.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants