Skip to content

Commit 89f106f

Browse files
committed
Update documentation on config file precedence
When working with ruff, I fell into the trap to have `.ruff.toml` and `pyproject.toml` config files. It took me some time to find the precedence rules from the docs. This PR aims to make the docs slightly more clear. - In the section "Config file discovery" the precedence was described quite lengthy at the very end of the section. I propose it's more concise to describe this with a single sentence immediately after stating that there can be one config file per directory.
1 parent bcefa45 commit 89f106f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

docs/configuration.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ directory hierarchy is used for every individual file, with all paths in the con
260260
(e.g., `exclude` globs, `src` paths) being resolved relative to the directory containing that
261261
config file.
262262

263+
If Ruff detects multiple configuration files in the same directory, the `.ruff.toml` file will take
264+
precedence over the `ruff.toml` file, and the `ruff.toml` file will take precedence over
265+
the `pyproject.toml` file.
266+
263267
There are a few exceptions to these rules:
264268

265269
1. In locating the "closest" `pyproject.toml` file for a given path, Ruff ignores any
@@ -302,11 +306,6 @@ config file, like so:
302306
line-length = 100
303307
```
304308

305-
All of the above rules apply equivalently to `pyproject.toml`, `ruff.toml`, and `.ruff.toml` files.
306-
If Ruff detects multiple configuration files in the same directory, the `.ruff.toml` file will take
307-
precedence over the `ruff.toml` file, and the `ruff.toml` file will take precedence over
308-
the `pyproject.toml` file.
309-
310309
### Inferring the Python version
311310
When no discovered configuration specifies a [`target-version`](settings.md#target-version), Ruff will attempt to fall back to the minimum version compatible with the `requires-python` field in a nearby `pyproject.toml`.
312311
The rules for this behavior are as follows:

0 commit comments

Comments
 (0)