I am subscribing to this issue about warning unused imports for python in visual studio code.
I am not particular about whether it's squiggle or gray out. But I am not certain if this feature is available based on the discussion or there's a workaround using a linter.
I am okay either way so long some detection is available.
I am using pylint as linter for now. Would be okay to use other linter so long I can detect unused imports.
And I do not want to auto remove unused imports.
This is what I see despite turning on pylint. I have purposely added an unused import. And I am not seeing any problems in this file.
Importchecker is a commandline utility to find unused imports in Python modules. Its output is “grep-like” (and thus “emacs-friendly”), reporting both the module's filenames and line numbers where names are imported that are not acually used in the module. Importchecker will not modify any of the source files.
To find unused members with a Code Analysis Ruleset, from the Visual Studio menu select File -> New -> File… -> General -> Code Analysis Rule Set. Uncheck all the rules.
Update/create VSCode user settings
"python.linting.pylintEnabled": true, "python.linting.pylintArgs": [ "--enable=W0614" ]
this works for me in Python 3.6.7 / 3.6.8
The Python extension for VS Code does not support warning about unused imports in its language server yet. But if you want Pylint to warn you, create a .pylintrc
and and turn on the W0611
warning.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With