小编Kev*_*ang的帖子

如何使用 VSCode 配置 Pylint?

对于我的设置,我有 Pylint ==3.0.0a4 和 VSCode 版本:1.67.2。在我的 VSCode settings.json 中,我有

"editor.formatOnSave": true,
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
Run Code Online (Sandbox Code Playgroud)

每次我保存 .py 文件时,VSCode 都会运行以下命令:

~/.local/share/virtualenvs/hello-world-n4ICiflw/bin/python ~/.vscode/extensions/ms-python.python-2022.6.2/pythonFiles/linter.py -m pylint ~/code/hello-world/src/main.py
Run Code Online (Sandbox Code Playgroud)

我相信 VSCode 通过代理调用运行 Python linter默认情况下linter.py -m pylint使用--output-format=json,但它失败并出现以下错误

##########Linting Output - pylint##########


[ERROR 2022-4-30 15:11:59.266]: Linter 'pylint' failed to parse the output '. [SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at s.parseMessages (/Users/kevinyang/.vscode/extensions/ms-python.python-2022.6.2/out/client/extension.js:2:518074)
    at s.run (/Users/kevinyang/.vscode/extensions/ms-python.python-2022.6.2/out/client/extension.js:2:499508)
    at async s.runLinter (/Users/kevinyang/.vscode/extensions/ms-python.python-2022.6.2/out/client/extension.js:2:517589)]
Run Code Online (Sandbox Code Playgroud)

看起来好像linter.py无法处理 pylint 生成的 JSON 输出。

我也尝试安装 Pylint 扩展,但遇到了同样的问题。

在 …

python pylint visual-studio-code

7
推荐指数
1
解决办法
8563
查看次数

标签 统计

pylint ×1

python ×1

visual-studio-code ×1