mirror of https://github.com/astral-sh/ruff
[`ruff`] Use `DiagnosticTag` for more pyupgrade rules (#20734)
This commit is contained in:
parent
5d3a35e071
commit
abbbe8f3af
|
|
@ -43,6 +43,7 @@ where
|
|||
T: Ranged,
|
||||
{
|
||||
let mut diagnostic = checker.report_diagnostic(DeprecatedCElementTree, node.range());
|
||||
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Deprecated);
|
||||
let contents = checker.locator().slice(node);
|
||||
diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement(
|
||||
contents.replacen("cElementTree", "ElementTree", 1),
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@ pub(crate) fn deprecated_mock_attribute(checker: &Checker, attribute: &ast::Expr
|
|||
},
|
||||
attribute.value.range(),
|
||||
);
|
||||
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Deprecated);
|
||||
diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement(
|
||||
"mock".to_string(),
|
||||
attribute.value.range(),
|
||||
|
|
@ -313,6 +314,7 @@ pub(crate) fn deprecated_mock_import(checker: &Checker, stmt: &Stmt) {
|
|||
},
|
||||
name.range(),
|
||||
);
|
||||
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Deprecated);
|
||||
if let Some(content) = content.as_ref() {
|
||||
diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement(
|
||||
content.clone(),
|
||||
|
|
@ -351,6 +353,7 @@ pub(crate) fn deprecated_mock_import(checker: &Checker, stmt: &Stmt) {
|
|||
},
|
||||
stmt.range(),
|
||||
);
|
||||
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Deprecated);
|
||||
if let Some(indent) = indentation(checker.source(), stmt) {
|
||||
diagnostic.try_set_fix(|| {
|
||||
format_import_from(stmt, indent, checker.locator(), checker.stylist())
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ pub(crate) fn deprecated_unittest_alias(checker: &Checker, expr: &Expr) {
|
|||
},
|
||||
expr.range(),
|
||||
);
|
||||
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Deprecated);
|
||||
diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement(
|
||||
format!("self.{target}"),
|
||||
expr.range(),
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ pub(crate) fn replace_universal_newlines(checker: &Checker, call: &ast::ExprCall
|
|||
};
|
||||
|
||||
let mut diagnostic = checker.report_diagnostic(ReplaceUniversalNewlines, arg.range());
|
||||
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Deprecated);
|
||||
|
||||
if call.arguments.find_keyword("text").is_some() {
|
||||
diagnostic.try_set_fix(|| {
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ pub(crate) fn typing_text_str_alias(checker: &Checker, expr: &Expr) {
|
|||
.is_some_and(|qualified_name| matches!(qualified_name.segments(), ["typing", "Text"]))
|
||||
{
|
||||
let mut diagnostic = checker.report_diagnostic(TypingTextStrAlias, expr.range());
|
||||
diagnostic.add_primary_tag(ruff_db::diagnostic::DiagnosticTag::Deprecated);
|
||||
diagnostic.try_set_fix(|| {
|
||||
let (import_edit, binding) = checker.importer().get_or_import_builtin_symbol(
|
||||
"str",
|
||||
|
|
|
|||
Loading…
Reference in New Issue