-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Idea: issue an error if a '# type: ignore' comment is unused #1345
Comments
This is a good idea! I think it should definitely be behind a flag, though -- it'd be annoying to cause errors in people's code whenever we fix a bug. Also, they may need the code to work across multiple mypy versions for some reason, which this would disallow. The fast parser transition is a concrete example: because it can change the line errors are assigned to, you'll need some extraneous type ignores during the transition period. |
It was @rwbarton's suggestion -- IIRC he said GHC has this. --Guido (mobile) This is a good idea! I think it should definitely be behind a flag, though — |
I think it's become clear that this is a good idea to have available behind a flag. I think I'd discourage running with this on in CI (because sometimes you need unused # type: ignores for forward compatibility), but it would be great to have for periodic sweeps. |
Yes! |
Even a simple version of this behind a flag will be useful, and I sort of promised this to the Zulip people, so I'll take a shot at this in the near future (traveling again this weekend but will still have time for mypy work). |
Potentially related request: could the same thing be accomplished for superfluous cast(some_obj, SomeType) when some_obj is already guaranteed to be SomeType? (Sample use case: in our codebase, we were doing a lot of IntEnum casting due to a mypy bug that was just fixed). |
Sounds like a good idea to me -- could even be the same flag, IMO. On Fri, Jun 10, 2016 at 5:29 PM, Max Wittek notifications@github.com
|
Yes! In fact, that is #958. Mypy itself has many redundant casts from before mypy understood isinstance checks; I removed about 60 of them a while ago but I'm sure there are a lot more. |
This commit also simplifies the handling of ignored_lines slightly, setting them once in the Errors object for each file file after it is parsed. Fixes python#1345.
This commit also simplifies the handling of ignored_lines slightly, setting them once in the Errors object for each file file after it is parsed. Fixes python#1345 and python#1739.
Sometimes we put in
# type: ignore
comments because of some mypy or typeshed bug (or a missing feature). It would be nice if mypy told us when we can take those out (e.g. because the bug is fixed).Maybe this should be a command-line flag, I can imagine it might be annoying occasionally too.
The text was updated successfully, but these errors were encountered: