From 10f65f8f08fc1f8a83e6f549c36e6b6efb54f93f Mon Sep 17 00:00:00 2001 From: doolio Date: Mon, 6 Nov 2023 11:52:46 +0100 Subject: [PATCH 1/2] docs: Add missing toml config tabs --- docs/faq.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 4e9ec14d2af1b..a794fec95eb09 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -360,6 +360,8 @@ the project root (as opposed to the directory of the file pointed to via the `ex For example, if you add a `ruff.toml` to the `tests` directory in the above example, you'll want to explicitly set the `src` option in the extended configuration file: +=== "ruff.toml" + ```toml # tests/ruff.toml extend = "../pyproject.toml" @@ -484,9 +486,9 @@ Run `ruff check /path/to/code.py --show-settings` to view the resolved settings Yes! In lieu of a `pyproject.toml` file, you can use a `ruff.toml` file for configuration. The two files are functionally equivalent and have an identical schema, with the exception that a `ruff.toml` -file can omit the `[tool.ruff]` section header. +file can omit the `[tool.ruff]` section header. For example: -For example, given this `pyproject.toml`: +=== "pyproject.toml" ```toml [tool.ruff] @@ -496,7 +498,7 @@ line-length = 88 convention = "google" ``` -You could instead use a `ruff.toml` file like so: +=== "ruff.toml" ```toml line-length = 88 From 231aff02c9bb3b0d754a15890f2fd20008a7da17 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 6 Nov 2023 16:04:56 -0500 Subject: [PATCH 2/2] Minor tweaks --- docs/faq.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index a794fec95eb09..ddc8007ae0579 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -357,16 +357,23 @@ If your `pyproject.toml`, `ruff.toml`, or `.ruff.toml` extends another configura will still use the directory containing your `pyproject.toml`, `ruff.toml`, or `.ruff.toml` file as the project root (as opposed to the directory of the file pointed to via the `extends` option). -For example, if you add a `ruff.toml` to the `tests` directory in the above example, you'll want to -explicitly set the `src` option in the extended configuration file: +For example, if you add a configuration file to the `tests` directory in the above example, you'll +want to explicitly set the `src` option in the extended configuration file: + +=== "pyproject.toml" + + ```toml + [tool.ruff] + extend = "../pyproject.toml" + src = ["../src"] + ``` === "ruff.toml" -```toml -# tests/ruff.toml -extend = "../pyproject.toml" -src = ["../src"] -``` + ```toml + extend = "../pyproject.toml" + src = ["../src"] + ``` Beyond this `src`-based detection, Ruff will also attempt to determine the current Python package for a given Python file, and mark imports from within the same package as first-party. For example, @@ -484,7 +491,7 @@ Run `ruff check /path/to/code.py --show-settings` to view the resolved settings ## I want to use Ruff, but I don't want to use `pyproject.toml`. What are my options? -Yes! In lieu of a `pyproject.toml` file, you can use a `ruff.toml` file for configuration. The two +In lieu of a `pyproject.toml` file, you can use a `ruff.toml` file for configuration. The two files are functionally equivalent and have an identical schema, with the exception that a `ruff.toml` file can omit the `[tool.ruff]` section header. For example: