From f9ffb3d50db14fca2c0fef84c77fcaf7aae92cbd Mon Sep 17 00:00:00 2001 From: Evan Rittenhouse Date: Wed, 21 Jun 2023 12:22:01 -0500 Subject: [PATCH] Add Applicability to pylint (#5251) --- .../pylint/rules/invalid_string_characters.rs | 3 +-- .../src/rules/pylint/rules/nested_min_max.rs | 3 +-- .../src/rules/pylint/rules/sys_exit_alias.rs | 3 +-- .../rules/pylint/rules/useless_import_alias.rs | 3 +-- ...t__tests__PLE2510_invalid_characters.py.snap | 2 +- ...t__tests__PLE2512_invalid_characters.py.snap | 2 +- ...t__tests__PLE2513_invalid_characters.py.snap | 2 +- ...t__tests__PLE2514_invalid_characters.py.snap | Bin 411 -> 401 bytes ...t__tests__PLE2515_invalid_characters.py.snap | 8 ++++---- 9 files changed, 11 insertions(+), 15 deletions(-) diff --git a/crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs b/crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs index 7a792d3bcbe09..3b5b28fcf3933 100644 --- a/crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs +++ b/crates/ruff/src/rules/pylint/rules/invalid_string_characters.rs @@ -191,8 +191,7 @@ pub(crate) fn invalid_string_characters(locator: &Locator, range: TextRange) -> let location = range.start() + TextSize::try_from(column).unwrap(); let range = TextRange::at(location, c.text_len()); - #[allow(deprecated)] - diagnostics.push(Diagnostic::new(rule, range).with_fix(Fix::unspecified( + diagnostics.push(Diagnostic::new(rule, range).with_fix(Fix::automatic( Edit::range_replacement(replacement.to_string(), range), ))); } diff --git a/crates/ruff/src/rules/pylint/rules/nested_min_max.rs b/crates/ruff/src/rules/pylint/rules/nested_min_max.rs index 4551376ef6bb8..1ca5ad354a552 100644 --- a/crates/ruff/src/rules/pylint/rules/nested_min_max.rs +++ b/crates/ruff/src/rules/pylint/rules/nested_min_max.rs @@ -157,8 +157,7 @@ pub(crate) fn nested_min_max( keywords: keywords.to_owned(), range: TextRange::default(), }); - #[allow(deprecated)] - diagnostic.set_fix(Fix::unspecified(Edit::range_replacement( + diagnostic.set_fix(Fix::suggested(Edit::range_replacement( checker.generator().expr(&flattened_expr), expr.range(), ))); diff --git a/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs b/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs index 72005b96a608e..c23bc22e6a6e5 100644 --- a/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs +++ b/crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs @@ -82,8 +82,7 @@ pub(crate) fn sys_exit_alias(checker: &mut Checker, func: &Expr) { checker.semantic(), )?; let reference_edit = Edit::range_replacement(binding, func.range()); - #[allow(deprecated)] - Ok(Fix::unspecified_edits(import_edit, [reference_edit])) + Ok(Fix::suggested_edits(import_edit, [reference_edit])) }); } checker.diagnostics.push(diagnostic); diff --git a/crates/ruff/src/rules/pylint/rules/useless_import_alias.rs b/crates/ruff/src/rules/pylint/rules/useless_import_alias.rs index 708de5926b88c..481be6265a6d5 100644 --- a/crates/ruff/src/rules/pylint/rules/useless_import_alias.rs +++ b/crates/ruff/src/rules/pylint/rules/useless_import_alias.rs @@ -49,8 +49,7 @@ pub(crate) fn useless_import_alias(checker: &mut Checker, alias: &Alias) { let mut diagnostic = Diagnostic::new(UselessImportAlias, alias.range()); if checker.patch(diagnostic.kind.rule()) { - #[allow(deprecated)] - diagnostic.set_fix(Fix::unspecified(Edit::range_replacement( + diagnostic.set_fix(Fix::suggested(Edit::range_replacement( asname.to_string(), alias.range(), ))); diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2510_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2510_invalid_characters.py.snap index 5760228fe28fe..7cba4adf6da41 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2510_invalid_characters.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2510_invalid_characters.py.snap @@ -12,7 +12,7 @@ invalid_characters.py:15:6: PLE2510 [*] Invalid unescaped character backspace, u | = help: Replace with escape sequence -ℹ Suggested fix +ℹ Fix 12 12 | # (Pylint, "C0414") => Rule::UselessImportAlias, 13 13 | # (Pylint, "C3002") => Rule::UnnecessaryDirectLambdaCall, 14 14 | #foo = 'hi' diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2512_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2512_invalid_characters.py.snap index 19aec0795a5d3..dbde22f71b420 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2512_invalid_characters.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2512_invalid_characters.py.snap @@ -12,7 +12,7 @@ invalid_characters.py:21:12: PLE2512 [*] Invalid unescaped character SUB, use "\ | = help: Replace with escape sequence -ℹ Suggested fix +ℹ Fix 18 18 | 19 19 | cr_ok = '\\r' 20 20 | diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2513_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2513_invalid_characters.py.snap index 2a080f617d86b..d8b61f4e13ec9 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2513_invalid_characters.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2513_invalid_characters.py.snap @@ -12,7 +12,7 @@ invalid_characters.py:25:16: PLE2513 [*] Invalid unescaped character ESC, use "\ | = help: Replace with escape sequence -ℹ Suggested fix +ℹ Fix 22 22 | 23 23 | sub_ok = '\x1a' 24 24 | diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2514_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2514_invalid_characters.py.snap index 9b1f9ba80aeb94978167822276aecea720ce6198..6adc278155badea216947efabd040490c3287c30 100644 GIT binary patch delta 13 UcmbQuJdt?=FC(MdWC_M*02ze?X8-^I delta 23 ecmbQpJezp~FC%wwX?l8UaY<^5LfT|L#%2Ik<_A&$ diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2515_invalid_characters.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2515_invalid_characters.py.snap index f6bdbe5ec525d..b12204f098e09 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2515_invalid_characters.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLE2515_invalid_characters.py.snap @@ -12,7 +12,7 @@ invalid_characters.py:34:13: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Suggested fix +ℹ Fix 31 31 | 32 32 | nul_ok = '\0' 33 33 | @@ -32,7 +32,7 @@ invalid_characters.py:38:36: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Suggested fix +ℹ Fix 35 35 | 36 36 | zwsp_ok = '\u200b' 37 37 | @@ -48,7 +48,7 @@ invalid_characters.py:39:60: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Suggested fix +ℹ Fix 36 36 | zwsp_ok = '\u200b' 37 37 | 38 38 | zwsp_after_multibyte_character = "ಫ​" @@ -63,7 +63,7 @@ invalid_characters.py:39:61: PLE2515 [*] Invalid unescaped character zero-width- | = help: Replace with escape sequence -ℹ Suggested fix +ℹ Fix 36 36 | zwsp_ok = '\u200b' 37 37 | 38 38 | zwsp_after_multibyte_character = "ಫ​"