mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 21:35:58 +00:00
Add settings for promoting and demoting fixes (#7841)
Adds two configuration-file only settings `extend-safe-fixes` and `extend-unsafe-fixes` which can be used to promote and demote the applicability of fixes for rules. Fixes with `Never` applicability cannot be promoted.
This commit is contained in:
parent
090c1a4a19
commit
739a8aa10e
9 changed files with 261 additions and 5 deletions
|
@ -523,6 +523,30 @@ pub struct LintOptions {
|
|||
)]
|
||||
pub ignore: Option<Vec<RuleSelector>>,
|
||||
|
||||
/// A list of rule codes or prefixes for which unsafe fixes should be considered
|
||||
/// safe.
|
||||
#[option(
|
||||
default = "[]",
|
||||
value_type = "list[RuleSelector]",
|
||||
example = r#"
|
||||
# Allow applying all unsafe fixes in the `E` rules and `F401` without the `--unsafe-fixes` flag
|
||||
extend_safe_fixes = ["E", "F401"]
|
||||
"#
|
||||
)]
|
||||
pub extend_safe_fixes: Option<Vec<RuleSelector>>,
|
||||
|
||||
/// A list of rule codes or prefixes for which safe fixes should be considered
|
||||
/// unsafe.
|
||||
#[option(
|
||||
default = "[]",
|
||||
value_type = "list[RuleSelector]",
|
||||
example = r#"
|
||||
# Require the `--unsafe-fixes` flag when fixing the `E` rules and `F401`
|
||||
extend_unsafe_fixes = ["E", "F401"]
|
||||
"#
|
||||
)]
|
||||
pub extend_unsafe_fixes: Option<Vec<RuleSelector>>,
|
||||
|
||||
/// Avoid automatically removing unused imports in `__init__.py` files. Such
|
||||
/// imports will still be flagged, but with a dedicated message suggesting
|
||||
/// that the import is either added to the module's `__all__` symbol, or
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue