Skip to content

Commit

Permalink
astral-sh#10342: Added ignore deprecated rules for 'select'
Browse files Browse the repository at this point in the history
  • Loading branch information
WindowGenerator committed Apr 14, 2024
1 parent ad84eed commit 5577cb0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions crates/ruff/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -879,10 +879,8 @@ fn nursery_all() {
-:1:1: RUF901 [*] Hey this is a stable test rule with a safe fix.
-:1:1: RUF902 Hey this is a stable test rule with an unsafe fix.
-:1:1: RUF903 Hey this is a stable test rule with a display only fix.
-:1:1: RUF920 Hey this is a deprecated test rule.
-:1:1: RUF921 Hey this is another deprecated test rule.
-:1:1: RUF950 Hey this is a test rule that was redirected from another.
Found 8 errors.
Found 6 errors.
[*] 1 fixable with the `--fix` option (1 hidden fix can be enabled with the `--unsafe-fixes` option).
----- stderr -----
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff_linter/src/rule_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ impl RuleSelector {
pub fn all_rules(&self) -> impl Iterator<Item = Rule> + '_ {
match self {
RuleSelector::All => RuleSelectorIter::All(Rule::iter()),

#[allow(deprecated)]
RuleSelector::Nursery => {
RuleSelectorIter::Nursery(Rule::iter().filter(Rule::is_nursery))
Expand Down Expand Up @@ -226,7 +225,8 @@ impl RuleSelector {
// is turned on
|| ((rule.is_preview() || rule.is_nursery()) && preview_enabled && (self.is_exact() || !preview_require_explicit))
// Deprecated rules are excluded in preview mode unless explicitly selected
|| (rule.is_deprecated() && (!preview_enabled || self.is_exact()))
// Ignore deprecated rules for All option
|| (rule.is_deprecated() && (!preview_enabled || self.is_exact()) && !matches!(self, RuleSelector::All { .. }))
// Removed rules are included if explicitly selected but will error downstream
|| (rule.is_removed() && self.is_exact())
})
Expand Down

0 comments on commit 5577cb0

Please sign in to comment.