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 26aa8f1384..21e633d189 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 @@ -291,12 +291,12 @@ help: Remove invalid suppression comment RUF100 [*] Unused suppression (non-enabled: `E501`) - --> suppressions.py:46:5 + --> suppressions.py:46:21 | 44 | # Neither of these are ignored and warnings are 45 | # logged to user 46 | # ruff: disable[E501] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^ 47 | I = 1 48 | # ruff: enable[E501] | @@ -311,12 +311,12 @@ help: Remove unused suppression RUF100 [*] Unused suppression (non-enabled: `E501`) - --> suppressions.py:48:5 + --> suppressions.py:48:20 | 46 | # ruff: disable[E501] 47 | I = 1 48 | # ruff: enable[E501] - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^ | help: Remove unused suppression 45 | # logged to user @@ -403,12 +403,12 @@ RUF104 Unmatched suppression comment RUF100 [*] Unused suppression (unused: `F841`) - --> suppressions.py:69:5 + --> suppressions.py:69:21 | 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 @@ -575,12 +575,12 @@ help: Remove unused suppression RUF102 [*] Invalid rule code in `# noqa`: YF829 - --> suppressions.py:93:5 + --> suppressions.py:93:21 | 91 | def f(): 92 | # Unknown rule codes 93 | # ruff: disable[YF829] - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ 94 | # ruff: disable[F841, RQW320] 95 | value = 0 | @@ -634,12 +634,12 @@ help: Remove the rule code RUF102 [*] Invalid rule code in `# noqa`: YF829 - --> suppressions.py:97:5 + --> suppressions.py:97:20 | 95 | value = 0 96 | # ruff: enable[F841, RQW320] 97 | # ruff: enable[YF829] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ | help: Remove the rule code 94 | # ruff: disable[F841, RQW320] diff --git a/crates/ruff_linter/src/suppression.rs b/crates/ruff_linter/src/suppression.rs index e9e9106d11..87d082409e 100644 --- a/crates/ruff_linter/src/suppression.rs +++ b/crates/ruff_linter/src/suppression.rs @@ -288,8 +288,9 @@ impl Suppressions { suppression: &Suppression, comment: &SuppressionComment, ) -> (TextRange, Edit) { - let mut range = comment.range; + let range: TextRange; let edit = if comment.codes.len() == 1 { + range = comment.codes[0]; delete_comment(comment.range, locator) } else { let code_index = comment