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
5 changes: 0 additions & 5 deletions crates/ruff_linter/src/checkers/noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ pub(crate) fn check_noqa(

if !(disabled_codes.is_empty()
&& duplicated_codes.is_empty()
&& unknown_codes.is_empty()
&& unmatched_codes.is_empty())
{
let edit = if valid_codes.is_empty() {
Expand Down Expand Up @@ -233,10 +232,6 @@ pub(crate) fn check_noqa(
.iter()
.map(|code| (*code).to_string())
.collect(),
unknown: unknown_codes
.iter()
.map(|code| (*code).to_string())
.collect(),
unmatched: unmatched_codes
.iter()
.map(|code| (*code).to_string())
Expand Down
23 changes: 6 additions & 17 deletions crates/ruff_linter/src/rules/ruff/rules/unused_noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::AlwaysFixableViolation;
pub(crate) struct UnusedCodes {
pub disabled: Vec<String>,
pub duplicated: Vec<String>,
pub unknown: Vec<String>,
pub unmatched: Vec<String>,
}

Expand Down Expand Up @@ -71,16 +70,16 @@ impl UnusedNOQAKind {
/// pass
/// ```
///
/// ## Options
/// ## See also
///
/// This rule will flag rule codes that are unknown to Ruff, even if they are
/// valid for other tools. You can tell Ruff to ignore such codes by configuring
/// the list of known "external" rule codes with the following option:
///
/// - `lint.external`
/// This rule ignores any codes that are unknown to Ruff, as it can't determine
/// if the codes are valid or used by other tools. Enable [`invalid-rule-code`][RUF102]
/// to flag any unknown rule codes.
///
/// ## References
/// - [Ruff error suppression](https://docs.astral.sh/ruff/linter/#error-suppression)
///
/// [RUF102]: https://docs.astral.sh/ruff/rules/invalid-rule-code/
#[derive(ViolationMetadata)]
#[violation_metadata(stable_since = "v0.0.155")]
pub(crate) struct UnusedNOQA {
Expand Down Expand Up @@ -124,16 +123,6 @@ impl AlwaysFixableViolation for UnusedNOQA {
.join(", ")
));
}
if !codes.unknown.is_empty() {
codes_by_reason.push(format!(
"unknown: {}",
codes
.unknown
.iter()
.map(|code| format!("`{code}`"))
.join(", ")
));
}
if codes_by_reason.is_empty() {
format!("Unused {}", self.kind.as_str())
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,6 @@ help: Remove unused `noqa` directive
24 | # Invalid (but external)
25 | d = 1 # noqa: V500

RUF100 [*] Unused `noqa` directive (unknown: `V500`)
--> RUF100_0.py:25:12
|
24 | # Invalid (but external)
25 | d = 1 # noqa: V500
| ^^^^^^^^^^^^
26 |
27 | # fmt: off
|
help: Remove unused `noqa` directive
22 | d = 1 # noqa: F841, V101
23 |
24 | # Invalid (but external)
- d = 1 # noqa: V500
25 + d = 1
26 |
27 | # fmt: off
28 | # Invalid - no space before #

RUF100 [*] Unused `noqa` directive (unused: `E501`)
--> RUF100_0.py:29:12
|
Expand Down Expand Up @@ -272,25 +253,6 @@ help: Remove unused `noqa` directive
95 |
96 | def f():

RUF100 [*] Unused `noqa` directive (unknown: `E50`)
--> RUF100_0.py:107:12
|
105 | def f():
106 | # Invalid - nonexistent error code with multibyte character
107 | d = 1 # …noqa: F841, E50
| ^^^^^^^^^^^^^^^^^
108 | e = 1 # …noqa: E50
|
help: Remove unused `noqa` directive
104 |
105 | def f():
106 | # Invalid - nonexistent error code with multibyte character
- d = 1 # …noqa: F841, E50
107 + d = 1 # noqa: F841
108 | e = 1 # …noqa: E50
109 |
110 |

F841 [*] Local variable `e` is assigned to but never used
--> RUF100_0.py:108:5
|
Expand All @@ -309,25 +271,7 @@ help: Remove assignment to unused variable `e`
110 | def f():
note: This is an unsafe fix and may change runtime behavior

RUF100 [*] Unused `noqa` directive (unknown: `E50`)
--> RUF100_0.py:108:12
|
106 | # Invalid - nonexistent error code with multibyte character
107 | d = 1 # …noqa: F841, E50
108 | e = 1 # …noqa: E50
| ^^^^^^^^^^^
|
help: Remove unused `noqa` directive
105 | def f():
106 | # Invalid - nonexistent error code with multibyte character
107 | d = 1 # …noqa: F841, E50
- e = 1 # …noqa: E50
108 + e = 1
109 |
110 |
111 | def f():

RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unknown: `X200`)
RUF100 [*] Unused `noqa` directive (duplicated: `F841`)
--> RUF100_0.py:118:12
|
116 | # Check duplicate code detection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,25 +253,6 @@ help: Remove unused `noqa` directive
95 |
96 | def f():

RUF100 [*] Unused `noqa` directive (unknown: `E50`)
--> RUF100_0.py:107:12
|
105 | def f():
106 | # Invalid - nonexistent error code with multibyte character
107 | d = 1 # …noqa: F841, E50
| ^^^^^^^^^^^^^^^^^
108 | e = 1 # …noqa: E50
|
help: Remove unused `noqa` directive
104 |
105 | def f():
106 | # Invalid - nonexistent error code with multibyte character
- d = 1 # …noqa: F841, E50
107 + d = 1 # noqa: F841
108 | e = 1 # …noqa: E50
109 |
110 |

F841 [*] Local variable `e` is assigned to but never used
--> RUF100_0.py:108:5
|
Expand All @@ -290,25 +271,7 @@ help: Remove assignment to unused variable `e`
110 | def f():
note: This is an unsafe fix and may change runtime behavior

RUF100 [*] Unused `noqa` directive (unknown: `E50`)
--> RUF100_0.py:108:12
|
106 | # Invalid - nonexistent error code with multibyte character
107 | d = 1 # …noqa: F841, E50
108 | e = 1 # …noqa: E50
| ^^^^^^^^^^^
|
help: Remove unused `noqa` directive
105 | def f():
106 | # Invalid - nonexistent error code with multibyte character
107 | d = 1 # …noqa: F841, E50
- e = 1 # …noqa: E50
108 + e = 1
109 |
110 |
111 | def f():

RUF100 [*] Unused `noqa` directive (duplicated: `F841`; unknown: `X200`)
RUF100 [*] Unused `noqa` directive (duplicated: `F841`)
--> RUF100_0.py:118:12
|
116 | # Check duplicate code detection
Expand Down
1 change: 0 additions & 1 deletion crates/ruff_linter/src/suppression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ impl Suppressions {
.iter()
.map(ToString::to_string)
.collect_vec(),
..Default::default()
}),
kind: UnusedNOQAKind::Suppression,
},
Expand Down