mirror of https://github.com/astral-sh/ruff
Fix test cases causing panics
This commit is contained in:
parent
61b48fbcc4
commit
e19ddb6e15
|
|
@ -313,11 +313,17 @@ mod tests {
|
|||
Rule::UnusedVariable,
|
||||
Rule::AmbiguousVariableName,
|
||||
Rule::UnusedNOQA,
|
||||
Rule::InvalidRuleCode,
|
||||
Rule::InvalidSuppressionComment,
|
||||
Rule::UnmatchedSuppressionComment,
|
||||
]),
|
||||
&settings::LinterSettings::for_rules(vec![
|
||||
Rule::UnusedVariable,
|
||||
Rule::AmbiguousVariableName,
|
||||
Rule::UnusedNOQA,
|
||||
Rule::InvalidRuleCode,
|
||||
Rule::InvalidSuppressionComment,
|
||||
Rule::UnmatchedSuppressionComment,
|
||||
])
|
||||
.with_preview_mode(),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pub(crate) struct InvalidSuppressionComment {
|
|||
pub kind: InvalidSuppressionCommentKind,
|
||||
}
|
||||
|
||||
impl Violation for InvalidSuppressionComment {
|
||||
impl AlwaysFixableViolation for InvalidSuppressionComment {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
let msg = match self.kind {
|
||||
|
|
@ -48,8 +48,8 @@ impl Violation for InvalidSuppressionComment {
|
|||
format!("Invalid suppression comment: {msg}")
|
||||
}
|
||||
|
||||
fn fix_title(&self) -> Option<String> {
|
||||
Some("Remove invalid suppression comment".to_string())
|
||||
fn fix_title(&self) -> String {
|
||||
"Remove invalid suppression comment".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ source: crates/ruff_linter/src/rules/ruff/mod.rs
|
|||
|
||||
--- Summary ---
|
||||
Removed: 14
|
||||
Added: 18
|
||||
Added: 19
|
||||
|
||||
--- Removed ---
|
||||
E741 Ambiguous variable name: `I`
|
||||
|
|
@ -251,6 +251,24 @@ RUF104 Unmatched suppression comment
|
|||
|
|
||||
|
||||
|
||||
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 invalid 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():
|
||||
|
||||
|
||||
RUF100 [*] Unused suppression (non-enabled: `E501`)
|
||||
--> suppressions.py:46:5
|
||||
|
|
||||
|
|
|
|||
|
|
@ -251,7 +251,6 @@ impl Suppressions {
|
|||
diagnostic.set_fix(Fix::safe_edit(delete_comment(error.range, locator)));
|
||||
}
|
||||
|
||||
// TODO: sometimes these don't get fixes attached?
|
||||
for invalid in &self.invalid {
|
||||
let mut diagnostic = context.report_diagnostic(
|
||||
InvalidSuppressionComment {
|
||||
|
|
|
|||
Loading…
Reference in New Issue