python - 在 python 3 的 visual studio 代码中检测未使用的导入?

标签 python visual-studio-code

我正在订阅此 issue关于在 Visual Studio 代码中警告未使用的 Python 导入。

我并不特别在意它是波浪线还是灰色。但根据讨论,我不确定此功能是否可用,或者是否有使用 linter 的解决方法。

只要可以进行一些检测,我都可以。

我现在使用 pylint 作为 linter。只要我能检测到未使用的导入,就可以使用其他 linter。

而且我不想自动删除未使用的导入。

这是我在打开 pylint 后看到的。我故意添加了一个未使用的导入。而且我在这个文件中没有看到任何问题。

enter image description here

最佳答案

更新/创建 VSCode 用户设置

"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
    "--enable=W0614"
]

这对我适用于 Python 3.6.7/3.6.8

关于python - 在 python 3 的 visual studio 代码中检测未使用的导入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53357649/

相关文章:

python - 将Column1值转换为标题,将Column2值转换为pandas中的值

python - 按值排序字典,然后按键排序

python - 进程以退出代码 139 结束(被信号 11 : SIGSEGV) 中断

json - 参数中带有双引号的 Visual Studio Code launch.json runtimeArgs

带有 VSCode 的 JavaFX-11

python - 为什么当 alpha 值中分母的幂增加到 13 或更多时,Ridge 模型拟合会显示警告?

python - 如何在 Python 中使用 XSLT 转换 XML 文件?

javascript - 如何在 VS Code 中获得更好的格式化?

javascript - 如何将@typedef 记录为@memberof a @namespace

git - 如何在 gitignore 中修复 .vscode 跟踪