繁体   English   中英

VSCode 在保存时不自动格式化(python - 黑色)

[英]VSCode not autoformatting on save (python - black)

我在 settings.json 中有以下代码

{ 
    "editor.formatOnSave": false,
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true
    },
    "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
    "python.linting.pylintArgs": [
        "--rcfile=${workspaceFolder}/.pylintrc"
    ],
    "python.linting.pylintEnabled": true,
    "python.linting.enabled": true,
}

我已经安装了以下扩展:

"ms-python.pylint"
"ms-python.black-formatter"

我在工作区中安装了黑色和 pylint 的 a.venv。

vscode 识别 pylint 错误,但不使用黑色规则格式化代码?

“editor.formatOnSave”:假,

false更改为true 并删除以下代码:

 "[python]": { "editor.defaultFormatter": "ms-python.black-formatter", "editor.formatOnSave": true },
  1. 在终端中运行命令pip install black

  2. 将以下代码添加到您的设置中setting.json

    “python.formatting.provider”:“黑色”,

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM