From b392368ecd8227b7b4e21546b87d3490e172495a Mon Sep 17 00:00:00 2001 From: Evan Rittenhouse Date: Wed, 21 Jun 2023 08:10:06 -0500 Subject: [PATCH 1/2] Add Applicability to pylint --- .../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 +-- ...lint__tests__PLC0414_import_aliasing.py.snap | 16 ++++++++-------- ...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 ++++---- ...int__tests__PLR1722_sys_exit_alias_0.py.snap | 8 ++++---- ...int__tests__PLR1722_sys_exit_alias_1.py.snap | 8 ++++---- ...int__tests__PLR1722_sys_exit_alias_2.py.snap | 8 ++++---- ...int__tests__PLR1722_sys_exit_alias_3.py.snap | 4 ++-- ...int__tests__PLR1722_sys_exit_alias_4.py.snap | 8 ++++---- ...int__tests__PLR1722_sys_exit_alias_6.py.snap | 4 ++-- ...int__tests__PLR1722_sys_exit_alias_7.py.snap | 2 +- ...int__tests__PLR1722_sys_exit_alias_8.py.snap | 2 +- ...int__tests__PLR1722_sys_exit_alias_9.py.snap | 2 +- 19 files changed, 42 insertions(+), 46 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..c92c2330bf815 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::automatic_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..89392c2acfa29 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::automatic(Edit::range_replacement( asname.to_string(), alias.range(), ))); diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap index a46cd982e0915..609368f0d589a 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap @@ -12,7 +12,7 @@ import_aliasing.py:6:8: PLC0414 [*] Import alias does not rename original packag | = help: Remove import alias -ℹ Suggested fix +ℹ Fix 3 3 | # 1. useless-import-alias 4 4 | # 2. consider-using-from-import 5 5 | @@ -32,7 +32,7 @@ import_aliasing.py:7:25: PLC0414 [*] Import alias does not rename original packa | = help: Remove import alias -ℹ Suggested fix +ℹ Fix 4 4 | # 2. consider-using-from-import 5 5 | 6 6 | import collections as collections # [useless-import-alias] @@ -53,7 +53,7 @@ import_aliasing.py:16:15: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Suggested fix +ℹ Fix 13 13 | import os 14 14 | import os as OS 15 15 | from sys import version @@ -74,7 +74,7 @@ import_aliasing.py:19:19: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Suggested fix +ℹ Fix 16 16 | from . import bar as bar # [useless-import-alias] 17 17 | from . import bar as Bar 18 18 | from . import bar @@ -95,7 +95,7 @@ import_aliasing.py:20:23: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Suggested fix +ℹ Fix 17 17 | from . import bar as Bar 18 18 | from . import bar 19 19 | from ..foo import bar as bar # [useless-import-alias] @@ -116,7 +116,7 @@ import_aliasing.py:22:15: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Suggested fix +ℹ Fix 19 19 | from ..foo import bar as bar # [useless-import-alias] 20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] 21 21 | from ..foo.bar import foobar as anotherfoobar @@ -137,7 +137,7 @@ import_aliasing.py:23:27: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Suggested fix +ℹ Fix 20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] 21 21 | from ..foo.bar import foobar as anotherfoobar 22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] @@ -158,7 +158,7 @@ import_aliasing.py:25:21: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Suggested fix +ℹ Fix 22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] 23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] 24 24 | from . import foo as bar, foo2 as bar2 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 = "ಫ​" diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap index 620f560648500..f45760e9dba1a 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_0.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 |-exit(0) 1 |+import sys 2 |+sys.exit(0) @@ -25,7 +25,7 @@ sys_exit_alias_0.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 |+import sys 1 2 | exit(0) 2 |-quit(0) @@ -43,7 +43,7 @@ sys_exit_alias_0.py:6:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 |+import sys 1 2 | exit(0) 2 3 | quit(0) @@ -63,7 +63,7 @@ sys_exit_alias_0.py:7:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 |+import sys 1 2 | exit(0) 2 3 | quit(0) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap index 0a57af4be9abb..e4d79221c2b89 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap @@ -11,7 +11,7 @@ sys_exit_alias_1.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 1 | import sys 2 2 | 3 |-exit(0) @@ -28,7 +28,7 @@ sys_exit_alias_1.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 1 | import sys 2 2 | 3 3 | exit(0) @@ -47,7 +47,7 @@ sys_exit_alias_1.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 5 5 | 6 6 | 7 7 | def main(): @@ -66,7 +66,7 @@ sys_exit_alias_1.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 6 6 | 7 7 | def main(): 8 8 | exit(1) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap index 7fe507657ccae..21d170122860b 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap @@ -11,7 +11,7 @@ sys_exit_alias_2.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 1 | import sys as sys2 2 2 | 3 |-exit(0) @@ -28,7 +28,7 @@ sys_exit_alias_2.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 1 | import sys as sys2 2 2 | 3 3 | exit(0) @@ -47,7 +47,7 @@ sys_exit_alias_2.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 5 5 | 6 6 | 7 7 | def main(): @@ -64,7 +64,7 @@ sys_exit_alias_2.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 6 6 | 7 7 | def main(): 8 8 | exit(1) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap index c969feedae81c..ae751f144ca39 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_3.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 1 | from sys import exit 2 2 | 3 3 | exit(0) @@ -28,7 +28,7 @@ sys_exit_alias_3.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 6 6 | 7 7 | def main(): 8 8 | exit(1) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap index d70b29f16db89..b59cebfec91c4 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap @@ -11,7 +11,7 @@ sys_exit_alias_4.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 1 | from sys import exit as exit2 2 2 | 3 |-exit(0) @@ -28,7 +28,7 @@ sys_exit_alias_4.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 1 | from sys import exit as exit2 2 2 | 3 3 | exit(0) @@ -47,7 +47,7 @@ sys_exit_alias_4.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 5 5 | 6 6 | 7 7 | def main(): @@ -64,7 +64,7 @@ sys_exit_alias_4.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 6 6 | 7 7 | def main(): 8 8 | exit(1) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap index 8f05fd18e27d2..e25c1525aa43b 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_6.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 |-exit(0) 1 |+import sys 2 |+sys.exit(0) @@ -25,7 +25,7 @@ sys_exit_alias_6.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 |+import sys 1 2 | exit(0) 2 |-quit(0) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap index 2ddf6a8a532b8..436f3165a03ac 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_7.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 |+import sys 1 2 | def main(): 2 |- exit(0) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap index 861d05a93f861..333d42461c579 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_8.py:5:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 |-from sys import argv 1 |+from sys import argv, exit 2 2 | diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap index a6be8caed6255..5079707d36cbe 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_9.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Suggested fix +ℹ Fix 1 |+import sys 1 2 | def main(): 2 |- exit(0) From b4fc955b463b42b58205294e999d5ef2d004ec76 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 21 Jun 2023 13:03:47 -0400 Subject: [PATCH 2/2] Tweaks --- .../src/rules/pylint/rules/sys_exit_alias.rs | 2 +- .../rules/pylint/rules/useless_import_alias.rs | 2 +- ...ylint__tests__PLC0414_import_aliasing.py.snap | 16 ++++++++-------- ...lint__tests__PLR1722_sys_exit_alias_0.py.snap | 8 ++++---- ...lint__tests__PLR1722_sys_exit_alias_1.py.snap | 8 ++++---- ...lint__tests__PLR1722_sys_exit_alias_2.py.snap | 8 ++++---- ...lint__tests__PLR1722_sys_exit_alias_3.py.snap | 4 ++-- ...lint__tests__PLR1722_sys_exit_alias_4.py.snap | 8 ++++---- ...lint__tests__PLR1722_sys_exit_alias_6.py.snap | 4 ++-- ...lint__tests__PLR1722_sys_exit_alias_7.py.snap | 2 +- ...lint__tests__PLR1722_sys_exit_alias_8.py.snap | 2 +- ...lint__tests__PLR1722_sys_exit_alias_9.py.snap | 2 +- 12 files changed, 33 insertions(+), 33 deletions(-) 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 c92c2330bf815..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,7 +82,7 @@ pub(crate) fn sys_exit_alias(checker: &mut Checker, func: &Expr) { checker.semantic(), )?; let reference_edit = Edit::range_replacement(binding, func.range()); - Ok(Fix::automatic_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 89392c2acfa29..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,7 +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()) { - diagnostic.set_fix(Fix::automatic(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__PLC0414_import_aliasing.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap index 609368f0d589a..a46cd982e0915 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLC0414_import_aliasing.py.snap @@ -12,7 +12,7 @@ import_aliasing.py:6:8: PLC0414 [*] Import alias does not rename original packag | = help: Remove import alias -ℹ Fix +ℹ Suggested fix 3 3 | # 1. useless-import-alias 4 4 | # 2. consider-using-from-import 5 5 | @@ -32,7 +32,7 @@ import_aliasing.py:7:25: PLC0414 [*] Import alias does not rename original packa | = help: Remove import alias -ℹ Fix +ℹ Suggested fix 4 4 | # 2. consider-using-from-import 5 5 | 6 6 | import collections as collections # [useless-import-alias] @@ -53,7 +53,7 @@ import_aliasing.py:16:15: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Fix +ℹ Suggested fix 13 13 | import os 14 14 | import os as OS 15 15 | from sys import version @@ -74,7 +74,7 @@ import_aliasing.py:19:19: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Fix +ℹ Suggested fix 16 16 | from . import bar as bar # [useless-import-alias] 17 17 | from . import bar as Bar 18 18 | from . import bar @@ -95,7 +95,7 @@ import_aliasing.py:20:23: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Fix +ℹ Suggested fix 17 17 | from . import bar as Bar 18 18 | from . import bar 19 19 | from ..foo import bar as bar # [useless-import-alias] @@ -116,7 +116,7 @@ import_aliasing.py:22:15: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Fix +ℹ Suggested fix 19 19 | from ..foo import bar as bar # [useless-import-alias] 20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] 21 21 | from ..foo.bar import foobar as anotherfoobar @@ -137,7 +137,7 @@ import_aliasing.py:23:27: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Fix +ℹ Suggested fix 20 20 | from ..foo.bar import foobar as foobar # [useless-import-alias] 21 21 | from ..foo.bar import foobar as anotherfoobar 22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] @@ -158,7 +158,7 @@ import_aliasing.py:25:21: PLC0414 [*] Import alias does not rename original pack | = help: Remove import alias -ℹ Fix +ℹ Suggested fix 22 22 | from . import foo as foo, foo2 as bar2 # [useless-import-alias] 23 23 | from . import foo as bar, foo2 as foo2 # [useless-import-alias] 24 24 | from . import foo as bar, foo2 as bar2 diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap index f45760e9dba1a..620f560648500 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_0.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_0.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 |-exit(0) 1 |+import sys 2 |+sys.exit(0) @@ -25,7 +25,7 @@ sys_exit_alias_0.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 |+import sys 1 2 | exit(0) 2 |-quit(0) @@ -43,7 +43,7 @@ sys_exit_alias_0.py:6:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 |+import sys 1 2 | exit(0) 2 3 | quit(0) @@ -63,7 +63,7 @@ sys_exit_alias_0.py:7:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 |+import sys 1 2 | exit(0) 2 3 | quit(0) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap index e4d79221c2b89..0a57af4be9abb 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_1.py.snap @@ -11,7 +11,7 @@ sys_exit_alias_1.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 1 | import sys 2 2 | 3 |-exit(0) @@ -28,7 +28,7 @@ sys_exit_alias_1.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 1 | import sys 2 2 | 3 3 | exit(0) @@ -47,7 +47,7 @@ sys_exit_alias_1.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 5 5 | 6 6 | 7 7 | def main(): @@ -66,7 +66,7 @@ sys_exit_alias_1.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 6 6 | 7 7 | def main(): 8 8 | exit(1) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap index 21d170122860b..7fe507657ccae 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_2.py.snap @@ -11,7 +11,7 @@ sys_exit_alias_2.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 1 | import sys as sys2 2 2 | 3 |-exit(0) @@ -28,7 +28,7 @@ sys_exit_alias_2.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 1 | import sys as sys2 2 2 | 3 3 | exit(0) @@ -47,7 +47,7 @@ sys_exit_alias_2.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 5 5 | 6 6 | 7 7 | def main(): @@ -64,7 +64,7 @@ sys_exit_alias_2.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 6 6 | 7 7 | def main(): 8 8 | exit(1) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap index ae751f144ca39..c969feedae81c 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_3.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_3.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 1 | from sys import exit 2 2 | 3 3 | exit(0) @@ -28,7 +28,7 @@ sys_exit_alias_3.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 6 6 | 7 7 | def main(): 8 8 | exit(1) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap index b59cebfec91c4..d70b29f16db89 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_4.py.snap @@ -11,7 +11,7 @@ sys_exit_alias_4.py:3:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 1 | from sys import exit as exit2 2 2 | 3 |-exit(0) @@ -28,7 +28,7 @@ sys_exit_alias_4.py:4:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 1 | from sys import exit as exit2 2 2 | 3 3 | exit(0) @@ -47,7 +47,7 @@ sys_exit_alias_4.py:8:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 5 5 | 6 6 | 7 7 | def main(): @@ -64,7 +64,7 @@ sys_exit_alias_4.py:9:5: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 6 6 | 7 7 | def main(): 8 8 | exit(1) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap index e25c1525aa43b..8f05fd18e27d2 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_6.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_6.py:1:1: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 |-exit(0) 1 |+import sys 2 |+sys.exit(0) @@ -25,7 +25,7 @@ sys_exit_alias_6.py:2:1: PLR1722 [*] Use `sys.exit()` instead of `quit` | = help: Replace `quit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 |+import sys 1 2 | exit(0) 2 |-quit(0) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap index 436f3165a03ac..2ddf6a8a532b8 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_7.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_7.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 |+import sys 1 2 | def main(): 2 |- exit(0) diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap index 333d42461c579..861d05a93f861 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_8.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_8.py:5:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 |-from sys import argv 1 |+from sys import argv, exit 2 2 | diff --git a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap index 5079707d36cbe..a6be8caed6255 100644 --- a/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap +++ b/crates/ruff/src/rules/pylint/snapshots/ruff__rules__pylint__tests__PLR1722_sys_exit_alias_9.py.snap @@ -9,7 +9,7 @@ sys_exit_alias_9.py:2:5: PLR1722 [*] Use `sys.exit()` instead of `exit` | = help: Replace `exit` with `sys.exit()` -ℹ Fix +ℹ Suggested fix 1 |+import sys 1 2 | def main(): 2 |- exit(0)