Using ruff for everything in VSCode
October 03, 2024
•
howto, astral, python, ruff, vscode
Ruff’s VSCode extension is nice, and can handle the jobs previously done by black and isort. To turn on everything, and to run this on every file save (this is probably what you want, given it only takes a few milliseconds), use this configuration in .vscode/settings.json:
{
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit",
},
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true
},
}