diff --git a/crates/ruff_linter/src/checkers/noqa.rs b/crates/ruff_linter/src/checkers/noqa.rs index d87e4343a9..2f83047932 100644 --- a/crates/ruff_linter/src/checkers/noqa.rs +++ b/crates/ruff_linter/src/checkers/noqa.rs @@ -12,7 +12,6 @@ use crate::fix::edits::delete_comment; use crate::noqa::{ Code, Directive, FileExemption, FileNoqaDirectives, NoqaDirectives, NoqaMapping, }; -use crate::preview::is_check_file_level_directives_enabled; use crate::registry::{AsRule, Rule, RuleSet}; use crate::rule_redirects::get_redirect_target; use crate::rules::pygrep_hooks; @@ -112,25 +111,16 @@ pub(crate) fn check_noqa( && !exemption.includes(Rule::UnusedNOQA) && !per_file_ignores.contains(Rule::UnusedNOQA) { - let directives: Vec<_> = if is_check_file_level_directives_enabled(settings) { - noqa_directives - .lines() - .iter() - .map(|line| (&line.directive, &line.matches, false)) - .chain( - file_noqa_directives - .lines() - .iter() - .map(|line| (&line.parsed_file_exemption, &line.matches, true)), - ) - .collect() - } else { - noqa_directives - .lines() - .iter() - .map(|line| (&line.directive, &line.matches, false)) - .collect() - }; + let directives = noqa_directives + .lines() + .iter() + .map(|line| (&line.directive, &line.matches, false)) + .chain( + file_noqa_directives + .lines() + .iter() + .map(|line| (&line.parsed_file_exemption, &line.matches, true)), + ); for (directive, matches, is_file_level) in directives { match directive { Directive::All(directive) => { diff --git a/crates/ruff_linter/src/preview.rs b/crates/ruff_linter/src/preview.rs index dcf496e1b6..6a3c7e818b 100644 --- a/crates/ruff_linter/src/preview.rs +++ b/crates/ruff_linter/src/preview.rs @@ -109,11 +109,6 @@ pub(crate) const fn is_allow_nested_roots_enabled(settings: &LinterSettings) -> settings.preview.is_enabled() } -// https://github.com/astral-sh/ruff/pull/17061 -pub(crate) const fn is_check_file_level_directives_enabled(settings: &LinterSettings) -> bool { - settings.preview.is_enabled() -} - // https://github.com/astral-sh/ruff/pull/18208 pub(crate) const fn is_multiple_with_statements_fix_safe_enabled( settings: &LinterSettings, diff --git a/crates/ruff_linter/src/rules/ruff/mod.rs b/crates/ruff_linter/src/rules/ruff/mod.rs index e3a0cd8ab5..39511fd353 100644 --- a/crates/ruff_linter/src/rules/ruff/mod.rs +++ b/crates/ruff_linter/src/rules/ruff/mod.rs @@ -324,10 +324,7 @@ mod tests { fn ruff_noqa_filedirective_unused() -> Result<()> { let diagnostics = test_path( Path::new("ruff/RUF100_6.py"), - &settings::LinterSettings { - preview: PreviewMode::Enabled, - ..settings::LinterSettings::for_rules(vec![Rule::UnusedNOQA]) - }, + &settings::LinterSettings::for_rules(vec![Rule::UnusedNOQA]), )?; assert_messages!(diagnostics); Ok(()) @@ -337,15 +334,12 @@ mod tests { fn ruff_noqa_filedirective_unused_last_of_many() -> Result<()> { let diagnostics = test_path( Path::new("ruff/RUF100_7.py"), - &settings::LinterSettings { - preview: PreviewMode::Enabled, - ..settings::LinterSettings::for_rules(vec![ - Rule::UnusedNOQA, - Rule::FStringMissingPlaceholders, - Rule::LineTooLong, - Rule::UnusedVariable, - ]) - }, + &settings::LinterSettings::for_rules(vec![ + Rule::UnusedNOQA, + Rule::FStringMissingPlaceholders, + Rule::LineTooLong, + Rule::UnusedVariable, + ]), )?; assert_messages!(diagnostics); Ok(())