I have the following code in settings.json
{
"editor.formatOnSave": false,
"[python]": {
"editor.defaultFormatter": "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",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With