For a project I have created a ruff.toml
file. In this file is among other things a different line-length defined. When ruff is used from the cli ruff format
it works as expected. But when I use Ruff: format document
from the extension it goes back to the line length defined in my VSCode settings.
This a part of all my settings, but these are all settings containing ruff
:
{
"ruff.format.args": [
"--line-length=79"
],
"ruff.configurationPreference": "filesystemFirst",
"editor.defaultFormatter": "charliermarsh.ruff",
"notebook.defaultFormatter": "charliermarsh.ruff",
}
I expect that this line: "ruff.configurationPreference": "filesystemFirst",
defines to first look a t the file system, if no .toml
file is found, then it should use the default settings.
In line with wath @InSync says, I found this solution:
Change this line
"ruff.format.args": [
"--line-length=79"
],
to:
"ruff.lineLength": 79,
Now ruff formats files (or folders) without a .toml file using the default settings (like this line length). If there is a .toml file ruff uses those settings.