-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Figure out how to detect unused imports #865
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
Not just unused imports, but all unused variables (that do not start with _). I think it's best to make mypy do this, controlled via a Related: #465 |
What needs to be done to help move this forward? |
Make a PR (assuming you are confident enough, since this might be not a small change). |
(Btw, latest versions of popular linters already understand/will soon understand type comments). |
Any pointers for where to get started on this?
Oh, is this due to the work on typed-ast, which would get adopted by the linters? |
Please ask a more specific question. Have you read the documentation, have
you tried something, what couldn't you get to work?
|
I believe linters now can detect PEP 484 type comments without issue (see e.g. PyCQA/pyflakes#400), so I think we can close this? |
Would be nice if mypy could support this, its one less tool is needed to lint a code base. This doesn't seem possible with the current plugin API, perhaps extending the plugin API to expose enough information to make this possible in third-party code would be good enough. |
Linters like
flake8
can detect unused imports, but this actually doesn't work with PEP 484 compliant code, as some of the uses can be in comments that are not seen by the linter. For example:We should either try to get linters fixed (file issues) or allow mypy to detect these kinds of errors reliably.
The text was updated successfully, but these errors were encountered: