diff --git a/crates/ruff/tests/cli/lint.rs b/crates/ruff/tests/cli/lint.rs index ec0bbc4f477b24..e12499b4b8fbb7 100644 --- a/crates/ruff/tests/cli/lint.rs +++ b/crates/ruff/tests/cli/lint.rs @@ -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 ----- @@ -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 diff --git a/crates/ruff_linter/src/checkers/noqa.rs b/crates/ruff_linter/src/checkers/noqa.rs index f984ef35767efe..a2ac6c208e5b83 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_range_suppressions_enabled; use crate::registry::Rule; use crate::rule_redirects::get_redirect_target; use crate::rules::pygrep_hooks; @@ -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; } diff --git a/crates/ruff_linter/src/linter.rs b/crates/ruff_linter/src/linter.rs index 8e8a85b8461b99..a25dd2ad42e5a4 100644 --- a/crates/ruff_linter/src/linter.rs +++ b/crates/ruff_linter/src/linter.rs @@ -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( @@ -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( @@ -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( @@ -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, diff --git a/crates/ruff_linter/src/preview.rs b/crates/ruff_linter/src/preview.rs index 76d5880614cfb3..82bb6e60c3b1a7 100644 --- a/crates/ruff_linter/src/preview.rs +++ b/crates/ruff_linter/src/preview.rs @@ -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() diff --git a/crates/ruff_linter/src/rules/pyflakes/mod.rs b/crates/ruff_linter/src/rules/pyflakes/mod.rs index dc91e21a18af7e..8098df0ce997f1 100644 --- a/crates/ruff_linter/src/rules/pyflakes/mod.rs +++ b/crates/ruff_linter/src/rules/pyflakes/mod.rs @@ -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(""), None, diff --git a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__range_suppressions.snap b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__range_suppressions.snap index ecd13aa023bb6a..a66f0e9f2c9f0c 100644 --- a/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__range_suppressions.snap +++ b/crates/ruff_linter/src/rules/ruff/snapshots/ruff_linter__rules__ruff__tests__range_suppressions.snap @@ -6,564 +6,5 @@ source: crates/ruff_linter/src/rules/ruff/mod.rs +linter.preview = enabled --- Summary --- -Removed: 15 -Added: 17 - ---- Removed --- -E741 Ambiguous variable name: `I` - --> suppressions.py:4:5 - | -2 | # These should both be ignored by the range suppression. -3 | # ruff: disable[E741, F841] -4 | I = 1 - | ^ -5 | # ruff: enable[E741, F841] - | - - -F841 [*] Local variable `I` is assigned to but never used - --> suppressions.py:4:5 - | -2 | # These should both be ignored by the range suppression. -3 | # ruff: disable[E741, F841] -4 | I = 1 - | ^ -5 | # ruff: enable[E741, F841] - | -help: Remove assignment to unused variable `I` -1 | def f(): -2 | # These should both be ignored by the range suppression. -3 | # ruff: disable[E741, F841] - - I = 1 -4 + pass -5 | # ruff: enable[E741, F841] -6 | -7 | -note: This is an unsafe fix and may change runtime behavior - - -E741 Ambiguous variable name: `I` - --> suppressions.py:12:5 - | -10 | # Should also generate an "unmatched suppression" warning. -11 | # ruff:disable[E741,F841] -12 | I = 1 - | ^ - | - - -F841 [*] Local variable `I` is assigned to but never used - --> suppressions.py:12:5 - | -10 | # Should also generate an "unmatched suppression" warning. -11 | # ruff:disable[E741,F841] -12 | I = 1 - | ^ - | -help: Remove assignment to unused variable `I` -9 | # These should both be ignored by the implicit range suppression. -10 | # Should also generate an "unmatched suppression" warning. -11 | # ruff:disable[E741,F841] - - I = 1 -12 + pass -13 | -14 | -15 | def f(): -note: This is an unsafe fix and may change runtime behavior - - -E741 Ambiguous variable name: `I` - --> suppressions.py:26:5 - | -24 | # the other logged to the user. -25 | # ruff: disable[E741] -26 | I = 1 - | ^ -27 | # ruff: enable[E741] - | - - -E741 Ambiguous variable name: `l` - --> suppressions.py:35:5 - | -33 | # middle line should be completely silenced. -34 | # ruff: disable[E741] -35 | l = 0 - | ^ -36 | # ruff: disable[F841] -37 | O = 1 - | - - -E741 Ambiguous variable name: `O` - --> suppressions.py:37:5 - | -35 | l = 0 -36 | # ruff: disable[F841] -37 | O = 1 - | ^ -38 | # ruff: enable[E741] -39 | I = 2 - | - - -F841 [*] Local variable `O` is assigned to but never used - --> suppressions.py:37:5 - | -35 | l = 0 -36 | # ruff: disable[F841] -37 | O = 1 - | ^ -38 | # ruff: enable[E741] -39 | I = 2 - | -help: Remove assignment to unused variable `O` -34 | # ruff: disable[E741] -35 | l = 0 -36 | # ruff: disable[F841] - - O = 1 -37 | # ruff: enable[E741] -38 | I = 2 -39 | # ruff: enable[F841] -note: This is an unsafe fix and may change runtime behavior - - -F841 [*] Local variable `I` is assigned to but never used - --> suppressions.py:39:5 - | -37 | O = 1 -38 | # ruff: enable[E741] -39 | I = 2 - | ^ -40 | # ruff: enable[F841] - | -help: Remove assignment to unused variable `I` -36 | # ruff: disable[F841] -37 | O = 1 -38 | # ruff: enable[E741] - - I = 2 -39 | # ruff: enable[F841] -40 | -41 | -note: This is an unsafe fix and may change runtime behavior - - -F841 [*] Local variable `foo` is assigned to but never used - --> suppressions.py:62:5 - | -60 | # Duplicate codes that are actually used. -61 | # ruff: disable[F841, F841] -62 | foo = 0 - | ^^^ - | -help: Remove assignment to unused variable `foo` -59 | def f(): -60 | # Duplicate codes that are actually used. -61 | # ruff: disable[F841, F841] - - foo = 0 -62 + pass -63 | -64 | -65 | def f(): -note: This is an unsafe fix and may change runtime behavior - - -F841 [*] Local variable `foo` is assigned to but never used - --> suppressions.py:70:5 - | -68 | # ruff: disable[F841] -69 | # ruff: disable[F841] -70 | foo = 0 - | ^^^ - | -help: Remove assignment to unused variable `foo` -67 | # and the other should trigger an unused suppression diagnostic -68 | # ruff: disable[F841] -69 | # ruff: disable[F841] - - foo = 0 -70 + pass -71 | -72 | -73 | def f(): -note: This is an unsafe fix and may change runtime behavior - - -F841 [*] Local variable `foo` is assigned to but never used - --> suppressions.py:76:5 - | -74 | # Multiple codes but only one is used -75 | # ruff: disable[E741, F401, F841] -76 | foo = 0 - | ^^^ - | -help: Remove assignment to unused variable `foo` -73 | def f(): -74 | # Multiple codes but only one is used -75 | # ruff: disable[E741, F401, F841] - - foo = 0 -76 + pass -77 | -78 | -79 | def f(): -note: This is an unsafe fix and may change runtime behavior - - -E741 Ambiguous variable name: `I` - --> suppressions.py:82:5 - | -80 | # Multiple codes but only two are used -81 | # ruff: disable[E741, F401, F841] -82 | I = 0 - | ^ - | - - -F841 [*] Local variable `I` is assigned to but never used - --> suppressions.py:82:5 - | -80 | # Multiple codes but only two are used -81 | # ruff: disable[E741, F401, F841] -82 | I = 0 - | ^ - | -help: Remove assignment to unused variable `I` -79 | def f(): -80 | # Multiple codes but only two are used -81 | # ruff: disable[E741, F401, F841] - - I = 0 -82 + pass -83 | -84 | -85 | def f(): -note: This is an unsafe fix and may change runtime behavior - - -F841 [*] Local variable `value` is assigned to but never used - --> suppressions.py:95:5 - | -93 | # ruff: disable[YF829] -94 | # ruff: disable[F841, RQW320] -95 | value = 0 - | ^^^^^ -96 | # ruff: enable[F841, RQW320] -97 | # ruff: enable[YF829] - | -help: Remove assignment to unused variable `value` -92 | # Unknown rule codes -93 | # ruff: disable[YF829] -94 | # ruff: disable[F841, RQW320] - - value = 0 -95 + pass -96 | # ruff: enable[F841, RQW320] -97 | # ruff: enable[YF829] -98 | -note: This is an unsafe fix and may change runtime behavior - - - ---- Added --- -RUF104 Suppression comment without matching `#ruff:enable` comment - --> suppressions.py:11:5 - | - 9 | # These should both be ignored by the implicit range suppression. -10 | # Should also generate an "unmatched suppression" warning. -11 | # ruff:disable[E741,F841] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ -12 | I = 1 - | - - -RUF103 [*] Invalid suppression comment: no matching 'disable' comment - --> suppressions.py:19:5 - | -17 | # should be generated. -18 | I = 1 -19 | # ruff: enable[E741, F841] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: Remove suppression comment -16 | # Neither warning is ignored, and an "unmatched suppression" -17 | # should be generated. -18 | I = 1 - - # ruff: enable[E741, F841] -19 | -20 | -21 | def f(): -note: This is an unsafe fix and may change runtime behavior - - -RUF100 [*] Unused suppression (non-enabled: `E501`) - --> suppressions.py:46:5 - | -44 | # Neither of these are ignored and warnings are -45 | # logged to user -46 | # ruff: disable[E501] - | ^^^^^^^^^^^^^^^^^^^^^ -47 | I = 1 -48 | # ruff: enable[E501] - | -------------------- - | -help: Remove unused suppression -43 | def f(): -44 | # Neither of these are ignored and warnings are -45 | # logged to user - - # ruff: disable[E501] -46 | I = 1 - - # ruff: enable[E501] -47 | -48 | -49 | def f(): - - -RUF100 [*] Unused `noqa` directive (unused: `E741`, `F841`) - --> suppressions.py:55:12 - | -53 | # and an unusued noqa diagnostic should be logged. -54 | # ruff:disable[E741,F841] -55 | I = 1 # noqa: E741,F841 - | ^^^^^^^^^^^^^^^^^ -56 | # ruff:enable[E741,F841] - | -help: Remove unused `noqa` directive -52 | # These should both be ignored by the range suppression, -53 | # and an unusued noqa diagnostic should be logged. -54 | # ruff:disable[E741,F841] - - I = 1 # noqa: E741,F841 -55 + I = 1 -56 | # ruff:enable[E741,F841] -57 | -58 | - - -RUF104 Suppression comment without matching `#ruff:enable` comment - --> suppressions.py:61:5 - | -59 | def f(): -60 | # Duplicate codes that are actually used. -61 | # ruff: disable[F841, F841] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -62 | foo = 0 - | - - -RUF100 [*] Unused suppression (duplicated: `F841`) - --> suppressions.py:61:5 - | -59 | def f(): -60 | # Duplicate codes that are actually used. -61 | # ruff: disable[F841, F841] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -62 | foo = 0 - | -help: Remove unused suppression -58 | -59 | def f(): -60 | # Duplicate codes that are actually used. - - # ruff: disable[F841, F841] -61 + # ruff: disable[F841] -62 | foo = 0 -63 | -64 | - - -RUF104 Suppression comment without matching `#ruff:enable` comment - --> suppressions.py:68:5 - | -66 | # Overlapping range suppressions, one should be marked as used, -67 | # and the other should trigger an unused suppression diagnostic -68 | # ruff: disable[F841] - | ^^^^^^^^^^^^^^^^^^^^^ -69 | # ruff: disable[F841] -70 | foo = 0 - | - - -RUF100 [*] Unused suppression (unused: `F841`) - --> suppressions.py:69:5 - | -67 | # and the other should trigger an unused suppression diagnostic -68 | # ruff: disable[F841] -69 | # ruff: disable[F841] - | ^^^^^^^^^^^^^^^^^^^^^ -70 | foo = 0 - | -help: Remove unused suppression -66 | # Overlapping range suppressions, one should be marked as used, -67 | # and the other should trigger an unused suppression diagnostic -68 | # ruff: disable[F841] - - # ruff: disable[F841] -69 | foo = 0 -70 | -71 | - - -RUF104 Suppression comment without matching `#ruff:enable` comment - --> suppressions.py:75:5 - | -73 | def f(): -74 | # Multiple codes but only one is used -75 | # ruff: disable[E741, F401, F841] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -76 | foo = 0 - | - - -RUF100 [*] Unused suppression (unused: `E741`; non-enabled: `F401`) - --> suppressions.py:75:5 - | -73 | def f(): -74 | # Multiple codes but only one is used -75 | # ruff: disable[E741, F401, F841] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -76 | foo = 0 - | -help: Remove unused suppression -72 | -73 | def f(): -74 | # Multiple codes but only one is used - - # ruff: disable[E741, F401, F841] -75 + # ruff: disable[F841] -76 | foo = 0 -77 | -78 | - - -RUF104 Suppression comment without matching `#ruff:enable` comment - --> suppressions.py:81:5 - | -79 | def f(): -80 | # Multiple codes but only two are used -81 | # ruff: disable[E741, F401, F841] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -82 | I = 0 - | - - -RUF100 [*] Unused suppression (non-enabled: `F401`) - --> suppressions.py:81:5 - | -79 | def f(): -80 | # Multiple codes but only two are used -81 | # ruff: disable[E741, F401, F841] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -82 | I = 0 - | -help: Remove unused suppression -78 | -79 | def f(): -80 | # Multiple codes but only two are used - - # ruff: disable[E741, F401, F841] -81 + # ruff: disable[E741, F841] -82 | I = 0 -83 | -84 | - - -RUF100 [*] Unused suppression (unused: `E741`, `F841`; non-enabled: `F401`) - --> suppressions.py:87:5 - | -85 | def f(): -86 | # Multiple codes but none are used -87 | # ruff: disable[E741, F401, F841] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -88 | print("hello") - | -help: Remove unused suppression -84 | -85 | def f(): -86 | # Multiple codes but none are used - - # ruff: disable[E741, F401, F841] -87 | print("hello") -88 | -89 | - - -RUF102 [*] Invalid rule code in suppression: YF829 - --> suppressions.py:93:21 - | -91 | def f(): -92 | # Unknown rule codes -93 | # ruff: disable[YF829] - | ^^^^^ -94 | # ruff: disable[F841, RQW320] -95 | value = 0 -96 | # ruff: enable[F841, RQW320] -97 | # ruff: enable[YF829] - | ----- - | -help: Remove the suppression comment -90 | -91 | def f(): -92 | # Unknown rule codes - - # ruff: disable[YF829] -93 | # ruff: disable[F841, RQW320] -94 | value = 0 -95 | # ruff: enable[F841, RQW320] - - # ruff: enable[YF829] -96 | -97 | -98 | def f(): - - -RUF102 [*] Invalid rule code in suppression: RQW320 - --> suppressions.py:94:27 - | -92 | # Unknown rule codes -93 | # ruff: disable[YF829] -94 | # ruff: disable[F841, RQW320] - | ^^^^^^ -95 | value = 0 -96 | # ruff: enable[F841, RQW320] - | ------ -97 | # ruff: enable[YF829] - | -help: Remove the rule code `RQW320` -91 | def f(): -92 | # Unknown rule codes -93 | # ruff: disable[YF829] - - # ruff: disable[F841, RQW320] -94 + # ruff: disable[F841] -95 | value = 0 - - # ruff: enable[F841, RQW320] -96 + # ruff: enable[F841] -97 | # ruff: enable[YF829] -98 | -99 | - - -RUF103 [*] Invalid suppression comment: missing suppression codes like `[E501, ...]` - --> suppressions.py:109:5 - | -107 | def f(): -108 | # Empty or missing rule codes -109 | # ruff: disable - | ^^^^^^^^^^^^^^^ -110 | # ruff: disable[] -111 | print("hello") - | -help: Remove suppression comment -106 | -107 | def f(): -108 | # Empty or missing rule codes - - # ruff: disable -109 | # ruff: disable[] -110 | print("hello") -note: This is an unsafe fix and may change runtime behavior - - -RUF103 [*] Invalid suppression comment: missing suppression codes like `[E501, ...]` - --> suppressions.py:110:5 - | -108 | # Empty or missing rule codes -109 | # ruff: disable -110 | # ruff: disable[] - | ^^^^^^^^^^^^^^^^^ -111 | print("hello") - | -help: Remove suppression comment -107 | def f(): -108 | # Empty or missing rule codes -109 | # ruff: disable - - # ruff: disable[] -110 | print("hello") -note: This is an unsafe fix and may change runtime behavior +Removed: 0 +Added: 0 diff --git a/crates/ruff_linter/src/suppression.rs b/crates/ruff_linter/src/suppression.rs index 9705f5ee1ceed5..521c18197c9f80 100644 --- a/crates/ruff_linter/src/suppression.rs +++ b/crates/ruff_linter/src/suppression.rs @@ -17,13 +17,11 @@ use smallvec::{SmallVec, smallvec}; use crate::checkers::ast::LintContext; use crate::codes::Rule; use crate::fix::edits::delete_comment; -use crate::preview::is_range_suppressions_enabled; use crate::rule_redirects::get_redirect_target; use crate::rules::ruff::rules::{ InvalidRuleCode, InvalidRuleCodeKind, InvalidSuppressionComment, InvalidSuppressionCommentKind, UnmatchedSuppressionComment, UnusedCodes, UnusedNOQA, UnusedNOQAKind, code_is_valid, }; -use crate::settings::LinterSettings; use crate::{Locator, Violation}; #[derive(Clone, Debug, Eq, PartialEq)] @@ -185,18 +183,9 @@ impl<'a> SuppressionDiagnostic<'a> { } impl Suppressions { - pub fn from_tokens( - settings: &LinterSettings, - source: &str, - tokens: &Tokens, - indexer: &Indexer, - ) -> Suppressions { - if is_range_suppressions_enabled(settings) { - let builder = SuppressionsBuilder::new(source); - builder.load_from_tokens(tokens, indexer) - } else { - Suppressions::default() - } + pub fn from_tokens(source: &str, tokens: &Tokens, indexer: &Indexer) -> Suppressions { + let builder = SuppressionsBuilder::new(source); + builder.load_from_tokens(tokens, indexer) } pub(crate) fn is_empty(&self) -> bool { @@ -836,12 +825,9 @@ mod tests { use ruff_text_size::{TextLen, TextRange, TextSize}; use similar::DiffableStr; - use crate::{ - settings::LinterSettings, - suppression::{ - InvalidSuppression, ParseError, Suppression, SuppressionAction, SuppressionComment, - SuppressionParser, Suppressions, - }, + use crate::suppression::{ + InvalidSuppression, ParseError, Suppression, SuppressionAction, SuppressionComment, + SuppressionParser, Suppressions, }; #[test] @@ -1727,12 +1713,7 @@ def bar(): fn debug(source: &'_ str) -> DebugSuppressions<'_> { let parsed = parse(source, ParseOptions::from(Mode::Module)).unwrap(); let indexer = Indexer::from_tokens(parsed.tokens(), source); - let suppressions = Suppressions::from_tokens( - &LinterSettings::default().with_preview_mode(), - source, - parsed.tokens(), - &indexer, - ); + let suppressions = Suppressions::from_tokens(source, parsed.tokens(), &indexer); DebugSuppressions { source, suppressions, diff --git a/crates/ruff_linter/src/test.rs b/crates/ruff_linter/src/test.rs index ce6d56018ca777..ed0547afd710d7 100644 --- a/crates/ruff_linter/src/test.rs +++ b/crates/ruff_linter/src/test.rs @@ -243,8 +243,7 @@ pub(crate) fn test_contents<'a>( &locator, &indexer, ); - let suppressions = - Suppressions::from_tokens(settings, locator.contents(), parsed.tokens(), &indexer); + let suppressions = Suppressions::from_tokens(locator.contents(), parsed.tokens(), &indexer); let messages = check_path( path, path.parent() @@ -312,7 +311,7 @@ pub(crate) fn test_contents<'a>( ); let suppressions = - Suppressions::from_tokens(settings, locator.contents(), parsed.tokens(), &indexer); + Suppressions::from_tokens(locator.contents(), parsed.tokens(), &indexer); let fixed_messages = check_path( path, None, diff --git a/crates/ruff_server/src/lint.rs b/crates/ruff_server/src/lint.rs index 2856f81db7240d..356f802a909738 100644 --- a/crates/ruff_server/src/lint.rs +++ b/crates/ruff_server/src/lint.rs @@ -120,12 +120,7 @@ pub(crate) fn check( let directives = extract_directives(parsed.tokens(), Flags::all(), &locator, &indexer); // Parse range suppression comments - let suppressions = Suppressions::from_tokens( - &settings.linter, - locator.contents(), - parsed.tokens(), - &indexer, - ); + let suppressions = Suppressions::from_tokens(locator.contents(), parsed.tokens(), &indexer); // Generate checks. let diagnostics = check_path( diff --git a/crates/ruff_wasm/src/lib.rs b/crates/ruff_wasm/src/lib.rs index 86ed523e7f9e81..67796575b00507 100644 --- a/crates/ruff_wasm/src/lib.rs +++ b/crates/ruff_wasm/src/lib.rs @@ -244,12 +244,7 @@ impl Workspace { &indexer, ); - let suppressions = Suppressions::from_tokens( - &self.settings.linter, - locator.contents(), - parsed.tokens(), - &indexer, - ); + let suppressions = Suppressions::from_tokens(locator.contents(), parsed.tokens(), &indexer); // Generate checks. let diagnostics = check_path( diff --git a/docs/linter.md b/docs/linter.md index d1e762c6526465..35ed415705bbcf 100644 --- a/docs/linter.md +++ b/docs/linter.md @@ -343,8 +343,6 @@ The full inline comment specification is as follows: #### Block-level -*Range suppressions are currently only available in [preview mode](preview.md#preview).* - To ignore one or more violations within a range or block of code, a "disable" comment followed by a matching "enable" comment can be used, like so: @@ -400,7 +398,7 @@ The full range suppression comment specification is as follows: - An own-line comment starting with case sensitive `#ruff:`, with optional whitespace after the `#` symbol and `:` symbol, followed by either `disable` or `enable` to start or end a range respectively, immediately followed by `[`, any codes to - be suppressed, and ending with `]`. + be suppressed, and ending with `]`. - Codes to be suppressed must be separated by commas, with optional whitespace before or after each code, and may be followed by an optional trailing comma after the last code.