mirror of https://github.com/astral-sh/ruff
[`ruff`] Use DiagnosticTag for more pyflakes and panda rules (#20801)
This commit is contained in:
parent
3c229ae58a
commit
b6b96d75eb
|
|
@ -130,6 +130,7 @@ pub(crate) fn check_noqa(
|
||||||
let edit = delete_comment(directive.range(), locator);
|
let edit = delete_comment(directive.range(), locator);
|
||||||
let mut diagnostic = context
|
let mut diagnostic = context
|
||||||
.report_diagnostic(UnusedNOQA { codes: None }, directive.range());
|
.report_diagnostic(UnusedNOQA { codes: None }, directive.range());
|
||||||
|
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Unnecessary);
|
||||||
diagnostic.set_fix(Fix::safe_edit(edit));
|
diagnostic.set_fix(Fix::safe_edit(edit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -226,6 +227,7 @@ pub(crate) fn check_noqa(
|
||||||
},
|
},
|
||||||
directive.range(),
|
directive.range(),
|
||||||
);
|
);
|
||||||
|
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Unnecessary);
|
||||||
diagnostic.set_fix(Fix::safe_edit(edit));
|
diagnostic.set_fix(Fix::safe_edit(edit));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -165,16 +165,17 @@ pub(crate) fn subscript(checker: &Checker, value: &Expr, expr: &Expr) {
|
||||||
match attr.as_str() {
|
match attr.as_str() {
|
||||||
// PD007
|
// PD007
|
||||||
"ix" if checker.is_rule_enabled(Rule::PandasUseOfDotIx) => {
|
"ix" if checker.is_rule_enabled(Rule::PandasUseOfDotIx) => {
|
||||||
checker.report_diagnostic(PandasUseOfDotIx, range)
|
let mut diagnostic = checker.report_diagnostic(PandasUseOfDotIx, range);
|
||||||
|
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Deprecated);
|
||||||
}
|
}
|
||||||
// PD008
|
// PD008
|
||||||
"at" if checker.is_rule_enabled(Rule::PandasUseOfDotAt) => {
|
"at" if checker.is_rule_enabled(Rule::PandasUseOfDotAt) => {
|
||||||
checker.report_diagnostic(PandasUseOfDotAt, range)
|
checker.report_diagnostic(PandasUseOfDotAt, range);
|
||||||
}
|
}
|
||||||
// PD009
|
// PD009
|
||||||
"iat" if checker.is_rule_enabled(Rule::PandasUseOfDotIat) => {
|
"iat" if checker.is_rule_enabled(Rule::PandasUseOfDotIat) => {
|
||||||
checker.report_diagnostic(PandasUseOfDotIat, range)
|
checker.report_diagnostic(PandasUseOfDotIat, range);
|
||||||
}
|
}
|
||||||
_ => return,
|
_ => (),
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ pub(crate) fn redefined_while_unused(checker: &Checker, scope_id: ScopeId, scope
|
||||||
},
|
},
|
||||||
binding.range(),
|
binding.range(),
|
||||||
);
|
);
|
||||||
|
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Unnecessary);
|
||||||
|
|
||||||
diagnostic.secondary_annotation(
|
diagnostic.secondary_annotation(
|
||||||
format_args!("previous definition of `{name}` here"),
|
format_args!("previous definition of `{name}` here"),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue