mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +00:00
Support negated patterns in [extend-]per-file-ignores (#10852)
Fixes #3172 ## Summary Allow prefixing [extend-]per-file-ignores patterns with `!` to negate the pattern; listed rules / prefixes will be ignored in all files that don't match the pattern. ## Test Plan Added tests for the feature. Rendered docs and checked rendered output.
This commit is contained in:
parent
42d52ebbec
commit
02e88fdbb1
5 changed files with 130 additions and 19 deletions
|
@ -905,7 +905,8 @@ pub struct LintCommonOptions {
|
|||
|
||||
// Tables are required to go last.
|
||||
/// A list of mappings from file pattern to rule codes or prefixes to
|
||||
/// exclude, when considering any matching files.
|
||||
/// exclude, when considering any matching files. An initial '!' negates
|
||||
/// the file pattern.
|
||||
#[option(
|
||||
default = "{}",
|
||||
value_type = "dict[str, list[RuleSelector]]",
|
||||
|
@ -914,6 +915,8 @@ pub struct LintCommonOptions {
|
|||
# Ignore `E402` (import violations) in all `__init__.py` files, and in `path/to/file.py`.
|
||||
"__init__.py" = ["E402"]
|
||||
"path/to/file.py" = ["E402"]
|
||||
# Ignore `D` rules everywhere except for the `src/` directory.
|
||||
"!src/**.py" = ["F401"]
|
||||
"#
|
||||
)]
|
||||
pub per_file_ignores: Option<FxHashMap<String, Vec<RuleSelector>>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue