Skip to content

Commit 97c092a

Browse files
Add formatter TOML configuration to the README (#7762)
## Summary This section is dated -- we now support configuration.
1 parent bdf2852 commit 97c092a

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

crates/ruff_python_formatter/README.md

+18-9
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,29 @@ on-save by adding `"editor.formatOnSave": true` to your `settings.json`:
102102

103103
### Configuration
104104

105-
The Ruff formatter respects Ruff's [`line-length`](https://docs.astral.sh/ruff/settings/#line-length)
106-
setting, which can be provided via a `pyproject.toml` or `ruff.toml` file, or on the CLI, as in:
105+
The Ruff formatter allows configuration of [indent style](https://docs.astral.sh/ruff/settings/#format-indent-style),
106+
[line ending](https://docs.astral.sh/ruff/settings/#format-line-ending), [quote style](https://docs.astral.sh/ruff/settings/#format-quote-style),
107+
and [magic trailing comma behavior](https://docs.astral.sh/ruff/settings/#format-skip-magic-trailing-comma).
108+
Like the linter, the Ruff formatter reads configuration via `pyproject.toml` or `ruff.toml` files,
109+
as in:
110+
111+
```toml
112+
[tool.ruff.format]
113+
# Use tabs instead of 4 space indentation
114+
indent-style = "tab"
115+
116+
# Prefer single quotes over double quotes
117+
quote-style = "single"
118+
```
119+
120+
The Ruff formatter also respects Ruff's [`line-length`](https://docs.astral.sh/ruff/settings/#line-length)
121+
setting, which also can be provided via a `pyproject.toml` or `ruff.toml` file, or on the CLI, as
122+
in:
107123

108124
```console
109125
ruff format --line-length 100 /path/to/file.py
110126
```
111127

112-
In future releases, the Ruff formatter will likely support configuration of:
113-
114-
- Quote style (single vs. double).
115-
- Line endings (LF vs. CRLF).
116-
- Indentation (tabs vs. spaces).
117-
- Tab width.
118-
119128
### Excluding code from formatting
120129

121130
Ruff supports Black's `# fmt: off`, `# fmt: on`, and `# fmt: skip` pragmas, with a few caveats.

0 commit comments

Comments
 (0)