[ruff] Use DiagnosticTag for more pyflakes and panda rules (#20801)

This commit is contained in:
Takayuki Maeda 2025-10-19 18:07:16 +09:00 committed by GitHub
parent 3c229ae58a
commit b6b96d75eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View file

@ -130,6 +130,7 @@ pub(crate) fn check_noqa(
let edit = delete_comment(directive.range(), locator);
let mut diagnostic = context
.report_diagnostic(UnusedNOQA { codes: None }, directive.range());
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Unnecessary);
diagnostic.set_fix(Fix::safe_edit(edit));
}
}
@ -226,6 +227,7 @@ pub(crate) fn check_noqa(
},
directive.range(),
);
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Unnecessary);
diagnostic.set_fix(Fix::safe_edit(edit));
}
}

View file

@ -165,16 +165,17 @@ pub(crate) fn subscript(checker: &Checker, value: &Expr, expr: &Expr) {
match attr.as_str() {
// PD007
"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
"at" if checker.is_rule_enabled(Rule::PandasUseOfDotAt) => {
checker.report_diagnostic(PandasUseOfDotAt, range)
checker.report_diagnostic(PandasUseOfDotAt, range);
}
// PD009
"iat" if checker.is_rule_enabled(Rule::PandasUseOfDotIat) => {
checker.report_diagnostic(PandasUseOfDotIat, range)
checker.report_diagnostic(PandasUseOfDotIat, range);
}
_ => return,
};
_ => (),
}
}

View file

@ -191,6 +191,7 @@ pub(crate) fn redefined_while_unused(checker: &Checker, scope_id: ScopeId, scope
},
binding.range(),
);
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Unnecessary);
diagnostic.secondary_annotation(
format_args!("previous definition of `{name}` here"),