-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Request: equivalent CLI option to ruff
's --add-noqa
to add type: ignore
comments
#16751
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
Comments
Turns out there are two third party projects for this: I tried using both of them today (2/6/2024), and they sort of work, but they both have bugs (e.g. not in sync with mypy latest release, broken by Imo it would be great to have this capability directly supported within |
I expect it is unlikely we could support this. Unlike most linters that work at the CST level, mypy works at the AST level, and any Instead, perhaps we can suggest using the mypy configurataion to skip checking modules that have more than N errors. It is much better IMO to start with checking only one or two modules that get used all over a code base than sprinkle type ignore everywhere and then go back and remove them gradually. Unlike with noqa, type ignores in this case are likely to be real type safety concerns, rather than style issues. If people are really compelled to this idea it could perhaps be implemented once there is an implementation of #7468, and as an extra step to suppressing the errors, modify the CST of affected files. |
I don't think this would be particularly difficult to do; we don't need to look at the AST or CST at all, but can find the line in the source file where the error is emitted and add I believe Pyre provides a similar feature. |
In particular, |
Feature
ruff
has an--add-noqa
option to addnoqa
directives in all places: https://docs.astral.sh/ruff/linter/#inserting-necessary-suppression-commentsIt would nice if
mypy
had something similar, like a--add-ignore
CLI argumentPitch
This would enable a new route to adopt
mypy
, mainly suppressing all type errors withtype: ignore
comments, and slowly removing them over time.The text was updated successfully, but these errors were encountered: