You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/configuration.md
+11-10Lines changed: 11 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -275,16 +275,6 @@ There are a few exceptions to these rules:
275
275
1. Any config-file-supported settings that are provided on the command-line (e.g., via
276
276
`--select`) will override the settings in _every_ resolved configuration file.
277
277
278
-
When no discovered configuration specifies a [`target-version`](settings.md#target-version), Ruff will attempt to fallback to the minimum version compatible with the `requires-python` field in a nearby `pyproject.toml`.
279
-
The rules for this behavior are as follows:
280
-
281
-
1. If a configuration file is passed directly, Ruff does not attempt to infer a missing `target-version`.
282
-
1. If a configuration file is found in the filesystem hierarchy, Ruff will infer a missing `target-version` from the `requires-python` field in a `pyproject.toml` file in the same directory as the found configuration.
283
-
1. If we are using a user-level configuration from `${config_dir}/ruff/pyproject.toml`, the `requires-python` field in the first `pyproject.toml` file found in an ancestor of the current working directory takes precedence over the `target-version` in the user-level configuration.
284
-
1. If no configuration files are found, Ruff will infer the `target-version` from the `requires-python` field in the first `pyproject.toml` file found in an ancestor of the current working directory.
285
-
286
-
Note that in these last two cases, the behavior of Ruff may differ depending on the working directory from which it is invoked.
Ruff does not merge settings across configuration files; instead, the "closest" configuration file
290
280
is used, and any parent configuration files are ignored. In lieu of this implicit cascade, Ruff
@@ -317,6 +307,17 @@ If Ruff detects multiple configuration files in the same directory, the `.ruff.t
317
307
precedence over the `ruff.toml` file, and the `ruff.toml` file will take precedence over
318
308
the `pyproject.toml` file.
319
309
310
+
### Inferring the Python version
311
+
When no discovered configuration specifies a [`target-version`](settings.md#target-version), Ruff will attempt to fallback to the minimum version compatible with the `requires-python` field in a nearby `pyproject.toml`.
312
+
The rules for this behavior are as follows:
313
+
314
+
1. If a configuration file is passed directly, Ruff does not attempt to infer a missing `target-version`.
315
+
1. If a configuration file is found in the filesystem hierarchy, Ruff will infer a missing `target-version` from the `requires-python` field in a `pyproject.toml` file in the same directory as the found configuration.
316
+
1. If we are using a user-level configuration from `${config_dir}/ruff/pyproject.toml`, the `requires-python` field in the first `pyproject.toml` file found in an ancestor of the current working directory takes precedence over the `target-version` in the user-level configuration.
317
+
1. If no configuration files are found, Ruff will infer the `target-version` from the `requires-python` field in the first `pyproject.toml` file found in an ancestor of the current working directory.
318
+
319
+
Note that in these last two cases, the behavior of Ruff may differ depending on the working directory from which it is invoked.
320
+
320
321
## Python file discovery
321
322
322
323
When passed a path on the command-line, Ruff will automatically discover all Python files in that
0 commit comments