![](/img/trans.png)
[英]Python VSCode formatOnSave with black not working in WSL
[英]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 },
在終端中運行命令pip install black
。
將以下代碼添加到您的設置中setting.json
:
“python.formatting.provider”:“黑色”,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.