Annoyed by some of the default rules? Wish ruff just fixed everything magically for you when it can?
Add this to your settings.json and it’ll automagically run the fixes on save.
{
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
}
}
}
If you want to limit the fixes it applies you can set this in pyproject.toml:
[tool.ruff.lint]
# Only auto-fix these rule families/codes
fixable = ["F401", "I"]
# Alternatively:
# fixable = ["ALL"]
# unfixable = ["F401"]

