From ef17c8299840a7202c7fbee820907b217b18135f Mon Sep 17 00:00:00 2001 From: Jan Katins Date: Fri, 13 Jan 2023 01:44:03 +0100 Subject: [PATCH] Document the way extend-ignore/select are applied (#1839) Closes: https://github.com/charliermarsh/ruff/issues/1838 --- README.md | 12 ++++++++++++ ruff.schema.json | 4 ++-- src/settings/options.rs | 12 ++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f3cc7d3dcb..9366602bc4 100644 --- a/README.md +++ b/README.md @@ -1908,6 +1908,12 @@ extend-exclude = ["tests", "src/bad.py"] A list of rule codes or prefixes to ignore, in addition to those specified by `ignore`. +Note that `extend-ignore` is applied after resolving rules from +`ignore`/`select` and a less specific rule in `extend-ignore` +would overwrite a more specific rule in `select`. It is +recommended to only use `extend-ignore` when extending a +`pyproject.toml` file via `extend`. + **Default value**: `[]` **Type**: `Vec` @@ -1927,6 +1933,12 @@ extend-ignore = ["F841"] A list of rule codes or prefixes to enable, in addition to those specified by `select`. +Note that `extend-select` is applied after resolving rules from +`ignore`/`select` and a less specific rule in `extend-select` +would overwrite a more specific rule in `ignore`. It is +recommended to only use `extend-select` when extending a +`pyproject.toml` file via `extend`. + **Default value**: `[]` **Type**: `Vec` diff --git a/ruff.schema.json b/ruff.schema.json index ea15aabe42..c382e80813 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -67,7 +67,7 @@ } }, "extend-ignore": { - "description": "A list of rule codes or prefixes to ignore, in addition to those specified by `ignore`.", + "description": "A list of rule codes or prefixes to ignore, in addition to those specified by `ignore`.\n\nNote that `extend-ignore` is applied after resolving rules from `ignore`/`select` and a less specific rule in `extend-ignore` would overwrite a more specific rule in `select`. It is recommended to only use `extend-ignore` when extending a `pyproject.toml` file via `extend`.", "type": [ "array", "null" @@ -77,7 +77,7 @@ } }, "extend-select": { - "description": "A list of rule codes or prefixes to enable, in addition to those specified by `select`.", + "description": "A list of rule codes or prefixes to enable, in addition to those specified by `select`.\n\nNote that `extend-select` is applied after resolving rules from `ignore`/`select` and a less specific rule in `extend-select` would overwrite a more specific rule in `ignore`. It is recommended to only use `extend-select` when extending a `pyproject.toml` file via `extend`.", "type": [ "array", "null" diff --git a/src/settings/options.rs b/src/settings/options.rs index 872aee6529..6fed0ee7eb 100644 --- a/src/settings/options.rs +++ b/src/settings/options.rs @@ -143,6 +143,12 @@ pub struct Options { )] /// A list of rule codes or prefixes to ignore, in addition to those /// specified by `ignore`. + /// + /// Note that `extend-ignore` is applied after resolving rules from + /// `ignore`/`select` and a less specific rule in `extend-ignore` + /// would overwrite a more specific rule in `select`. It is + /// recommended to only use `extend-ignore` when extending a + /// `pyproject.toml` file via `extend`. pub extend_ignore: Option>, #[option( default = "[]", @@ -154,6 +160,12 @@ pub struct Options { )] /// A list of rule codes or prefixes to enable, in addition to those /// specified by `select`. + /// + /// Note that `extend-select` is applied after resolving rules from + /// `ignore`/`select` and a less specific rule in `extend-select` + /// would overwrite a more specific rule in `ignore`. It is + /// recommended to only use `extend-select` when extending a + /// `pyproject.toml` file via `extend`. pub extend_select: Option>, #[option( default = "[]",