Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions crates/ruff/tests/cli/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1539,22 +1539,6 @@ import sys
.args(["--config", "ruff.toml"])
.arg("noqa.py"),
@"
success: false
exit_code: 1
----- stdout -----
noqa.py:5:8: F401 [*] `sys` imported but unused
Found 1 error.
[*] 1 fixable with the `--fix` option.

----- stderr -----
");

assert_cmd_snapshot!(fixture
.check_command()
.args(["--config", "ruff.toml"])
.arg("noqa.py")
.args(["--preview"]),
@"
success: true
exit_code: 0
----- stdout -----
Expand All @@ -1563,12 +1547,12 @@ import sys
----- stderr -----
");

// with --ignore-noqa --preview
// with --ignore-noqa
assert_cmd_snapshot!(fixture
.check_command()
.args(["--config", "ruff.toml"])
.arg("noqa.py")
.args(["--ignore-noqa", "--preview"]),
.args(["--ignore-noqa"]),
@"
success: false
exit_code: 1
Expand Down
3 changes: 1 addition & 2 deletions crates/ruff_linter/src/checkers/noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::fix::edits::delete_comment;
use crate::noqa::{
Code, Directive, FileExemption, FileNoqaDirectives, NoqaDirectives, NoqaMapping,
};
use crate::preview::is_range_suppressions_enabled;
use crate::registry::Rule;
use crate::rule_redirects::get_redirect_target;
use crate::rules::pygrep_hooks;
Expand Down Expand Up @@ -71,7 +70,7 @@ pub(crate) fn check_noqa(
}

// Apply ranged suppressions next
if is_range_suppressions_enabled(settings) && suppressions.check_diagnostic(diagnostic) {
if suppressions.check_diagnostic(diagnostic) {
ignored_diagnostics.push(index);
continue;
}
Expand Down
12 changes: 4 additions & 8 deletions crates/ruff_linter/src/linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,7 @@ pub fn add_noqa_to_path(
);

// Parse range suppression comments
let suppressions =
Suppressions::from_tokens(settings, locator.contents(), parsed.tokens(), &indexer);
let suppressions = Suppressions::from_tokens(locator.contents(), parsed.tokens(), &indexer);

// Generate diagnostics, ignoring any existing `noqa` directives.
let diagnostics = check_path(
Expand Down Expand Up @@ -480,8 +479,7 @@ pub fn lint_only(
);

// Parse range suppression comments
let suppressions =
Suppressions::from_tokens(settings, locator.contents(), parsed.tokens(), &indexer);
let suppressions = Suppressions::from_tokens(locator.contents(), parsed.tokens(), &indexer);

// Generate diagnostics.
let diagnostics = check_path(
Expand Down Expand Up @@ -598,8 +596,7 @@ pub fn lint_fix<'a>(
);

// Parse range suppression comments
let suppressions =
Suppressions::from_tokens(settings, locator.contents(), parsed.tokens(), &indexer);
let suppressions = Suppressions::from_tokens(locator.contents(), parsed.tokens(), &indexer);

// Generate diagnostics.
let diagnostics = check_path(
Expand Down Expand Up @@ -981,8 +978,7 @@ mod tests {
&locator,
&indexer,
);
let suppressions =
Suppressions::from_tokens(settings, locator.contents(), parsed.tokens(), &indexer);
let suppressions = Suppressions::from_tokens(locator.contents(), parsed.tokens(), &indexer);
let mut diagnostics = check_path(
path,
None,
Expand Down
5 changes: 0 additions & 5 deletions crates/ruff_linter/src/preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,6 @@ pub(crate) const fn is_s310_resolve_string_literal_bindings_enabled(
settings.preview.is_enabled()
}

// https://github.com/astral-sh/ruff/pull/21623
pub(crate) const fn is_range_suppressions_enabled(settings: &LinterSettings) -> bool {
settings.preview.is_enabled()
}

// https://github.com/astral-sh/ruff/pull/22057
pub(crate) const fn is_ble001_exc_info_suppression_enabled(settings: &LinterSettings) -> bool {
settings.preview.is_enabled()
Expand Down
3 changes: 1 addition & 2 deletions crates/ruff_linter/src/rules/pyflakes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -965,8 +965,7 @@ mod tests {
&locator,
&indexer,
);
let suppressions =
Suppressions::from_tokens(&settings, locator.contents(), parsed.tokens(), &indexer);
let suppressions = Suppressions::from_tokens(locator.contents(), parsed.tokens(), &indexer);
let mut messages = check_path(
Path::new("<filename>"),
None,
Expand Down
Loading