Skip to content

Commit

Permalink
Add Applicability to pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Jun 21, 2023
1 parent 44156f6 commit b392368
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)));
}
Expand Down
3 changes: 1 addition & 2 deletions crates/ruff/src/rules/pylint/rules/nested_min_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)));
Expand Down
3 changes: 1 addition & 2 deletions crates/ruff/src/rules/pylint/rules/sys_exit_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions crates/ruff/src/rules/pylint/rules/useless_import_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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 |
Expand All @@ -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 = "ಫ​"
Expand All @@ -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 = "ಫ​"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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():
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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():
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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():
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b392368

Please sign in to comment.