I have the following code in 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,
}
I have installed the following extensions:
"ms-python.pylint"
"ms-python.black-formatter"
I have a.venv in the workspace with black and pylint installed.
vscode recognizes pylint errors, but doesn't format the code with the black rules?
"editor.formatOnSave": false,
Change false to true . And delete the following code:
"[python]": { "editor.defaultFormatter": "ms-python.black-formatter", "editor.formatOnSave": true },
Run the command pip install black
in your terminal.
Add the following code to your setting.json
:
"python.formatting.provider": "black",
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.