Reputation: 156
How do I convince ruff and VS Code to actually Format document on save? What I mean is that when I save a Python file, and do "Ruff: Format document", I get different results. I want saving a file to also run "Ruff: Format Document." How do I do that?
For example, if I start with
import os
import abc
def what():
return 'hey'
when I save the document I get:
def what():
return "hey"
with "Ruff: Format document" I get:
import os
import abc
def what():
return "hey"
Note that in both cases the single quoted 'hey'
was fixed to double quoted "hey"
which is good.
How do I get saving the document to do "Ruff: Format document"?
Here's pertinent section of my settings.json
"[python]": {
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
},
Upvotes: 1
Views: 652