mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Add autofix specification levels for a variety of rules (#5109)
This commit is contained in:
parent
c654280d84
commit
ed8113267c
53 changed files with 344 additions and 370 deletions
|
@ -62,8 +62,7 @@ pub(crate) fn commented_out_code(
|
|||
let mut diagnostic = Diagnostic::new(CommentedOutCode, *range);
|
||||
|
||||
if settings.rules.should_fix(Rule::CommentedOutCode) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_deletion(
|
||||
diagnostic.set_fix(Fix::manual(Edit::range_deletion(
|
||||
locator.full_lines_range(*range),
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ ERA001.py:1:1: ERA001 [*] Found commented-out code
|
|||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
1 |-#import os
|
||||
2 1 | # from foo import junk
|
||||
3 2 | #a = 3
|
||||
|
@ -26,7 +26,7 @@ ERA001.py:2:1: ERA001 [*] Found commented-out code
|
|||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
1 1 | #import os
|
||||
2 |-# from foo import junk
|
||||
3 2 | #a = 3
|
||||
|
@ -44,7 +44,7 @@ ERA001.py:3:1: ERA001 [*] Found commented-out code
|
|||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
1 1 | #import os
|
||||
2 2 | # from foo import junk
|
||||
3 |-#a = 3
|
||||
|
@ -63,7 +63,7 @@ ERA001.py:5:1: ERA001 [*] Found commented-out code
|
|||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
2 2 | # from foo import junk
|
||||
3 3 | #a = 3
|
||||
4 4 | a = 4
|
||||
|
@ -82,7 +82,7 @@ ERA001.py:13:5: ERA001 [*] Found commented-out code
|
|||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
10 10 |
|
||||
11 11 | # This is a real comment.
|
||||
12 12 | # # This is a (nested) comment.
|
||||
|
@ -100,7 +100,7 @@ ERA001.py:21:5: ERA001 [*] Found commented-out code
|
|||
|
|
||||
= help: Remove commented-out code
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
18 18 |
|
||||
19 19 | class A():
|
||||
20 20 | pass
|
||||
|
|
|
@ -53,7 +53,6 @@ pub(crate) fn assert_false(checker: &mut Checker, stmt: &Stmt, test: &Expr, msg:
|
|||
|
||||
let mut diagnostic = Diagnostic::new(AssertFalse, test.range());
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::suggested(Edit::range_replacement(
|
||||
checker.generator().stmt(&assertion_error(msg)),
|
||||
stmt.range(),
|
||||
|
|
|
@ -89,8 +89,7 @@ fn duplicate_handler_exceptions<'a>(
|
|||
expr.range(),
|
||||
);
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::suggested(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
if unique_elts.len() == 1 {
|
||||
checker.generator().expr(unique_elts[0])
|
||||
} else {
|
||||
|
|
|
@ -12,7 +12,7 @@ B014.py:17:8: B014 [*] Exception handler with duplicate exception: `OSError`
|
|||
|
|
||||
= help: De-duplicate exceptions
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
14 14 |
|
||||
15 15 | try:
|
||||
16 16 | pass
|
||||
|
@ -33,7 +33,7 @@ B014.py:28:8: B014 [*] Exception handler with duplicate exception: `MyError`
|
|||
|
|
||||
= help: De-duplicate exceptions
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
25 25 |
|
||||
26 26 | try:
|
||||
27 27 | pass
|
||||
|
@ -54,7 +54,7 @@ B014.py:49:8: B014 [*] Exception handler with duplicate exception: `re.error`
|
|||
|
|
||||
= help: De-duplicate exceptions
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
46 46 |
|
||||
47 47 | try:
|
||||
48 48 | pass
|
||||
|
|
|
@ -56,8 +56,7 @@ pub(crate) fn shebang_whitespace(
|
|||
TextRange::at(range.start(), *n_spaces),
|
||||
);
|
||||
if autofix {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_deletion(TextRange::at(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_deletion(TextRange::at(
|
||||
range.start(),
|
||||
*n_spaces,
|
||||
))));
|
||||
|
|
|
@ -8,7 +8,7 @@ EXE004_1.py:1:1: EXE004 [*] Avoid whitespace before shebang
|
|||
|
|
||||
= help: Remove whitespace before shebang
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 |- #!/usr/bin/python
|
||||
1 |+#!/usr/bin/python
|
||||
|
||||
|
|
|
@ -77,8 +77,7 @@ fn traverse_union<'a>(
|
|||
};
|
||||
|
||||
// Replace the parent with its non-duplicate child.
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
checker
|
||||
.generator()
|
||||
.expr(if expr == left.as_ref() { right } else { left }),
|
||||
|
|
|
@ -24,8 +24,7 @@ impl AlwaysAutofixableViolation for QuotedAnnotationInStub {
|
|||
pub(crate) fn quoted_annotation_in_stub(checker: &mut Checker, annotation: &str, range: TextRange) {
|
||||
let mut diagnostic = Diagnostic::new(QuotedAnnotationInStub, range);
|
||||
if checker.patch(Rule::QuotedAnnotationInStub) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
annotation.to_string(),
|
||||
range,
|
||||
)));
|
||||
|
|
|
@ -11,7 +11,7 @@ PYI016.pyi:5:15: PYI016 [*] Duplicate union member `str`
|
|||
|
|
||||
= help: Remove duplicate union member `str`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
2 2 | field1: str
|
||||
3 3 |
|
||||
4 4 | # Should emit for duplicate field types.
|
||||
|
@ -30,7 +30,7 @@ PYI016.pyi:8:23: PYI016 [*] Duplicate union member `int`
|
|||
|
|
||||
= help: Remove duplicate union member `int`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
5 5 | field2: str | str # PYI016: Duplicate union member `str`
|
||||
6 6 |
|
||||
7 7 | # Should emit for union types in arguments.
|
||||
|
@ -49,7 +49,7 @@ PYI016.pyi:12:22: PYI016 [*] Duplicate union member `str`
|
|||
|
|
||||
= help: Remove duplicate union member `str`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
9 9 | print(arg1)
|
||||
10 10 |
|
||||
11 11 | # Should emit for unions in return types.
|
||||
|
@ -69,7 +69,7 @@ PYI016.pyi:16:15: PYI016 [*] Duplicate union member `str`
|
|||
|
|
||||
= help: Remove duplicate union member `str`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
13 13 | return "my string"
|
||||
14 14 |
|
||||
15 15 | # Should emit in longer unions, even if not directly adjacent.
|
||||
|
@ -90,7 +90,7 @@ PYI016.pyi:17:15: PYI016 [*] Duplicate union member `int`
|
|||
|
|
||||
= help: Remove duplicate union member `int`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
14 14 |
|
||||
15 15 | # Should emit in longer unions, even if not directly adjacent.
|
||||
16 16 | field3: str | str | int # PYI016: Duplicate union member `str`
|
||||
|
@ -110,7 +110,7 @@ PYI016.pyi:18:21: PYI016 [*] Duplicate union member `str`
|
|||
|
|
||||
= help: Remove duplicate union member `str`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
15 15 | # Should emit in longer unions, even if not directly adjacent.
|
||||
16 16 | field3: str | str | int # PYI016: Duplicate union member `str`
|
||||
17 17 | field4: int | int | str # PYI016: Duplicate union member `int`
|
||||
|
@ -131,7 +131,7 @@ PYI016.pyi:19:28: PYI016 [*] Duplicate union member `int`
|
|||
|
|
||||
= help: Remove duplicate union member `int`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
16 16 | field3: str | str | int # PYI016: Duplicate union member `str`
|
||||
17 17 | field4: int | int | str # PYI016: Duplicate union member `int`
|
||||
18 18 | field5: str | int | str # PYI016: Duplicate union member `str`
|
||||
|
@ -151,7 +151,7 @@ PYI016.pyi:25:22: PYI016 [*] Duplicate union member `int`
|
|||
|
|
||||
= help: Remove duplicate union member `int`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
22 22 | field7 = str | str
|
||||
23 23 |
|
||||
24 24 | # Should emit for strangely-bracketed unions.
|
||||
|
@ -170,7 +170,7 @@ PYI016.pyi:28:16: PYI016 [*] Duplicate union member `int`
|
|||
|
|
||||
= help: Remove duplicate union member `int`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
25 25 | field8: int | (str | int) # PYI016: Duplicate union member `int`
|
||||
26 26 |
|
||||
27 27 | # Should handle user brackets when fixing.
|
||||
|
@ -191,7 +191,7 @@ PYI016.pyi:29:24: PYI016 [*] Duplicate union member `str`
|
|||
|
|
||||
= help: Remove duplicate union member `str`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
26 26 |
|
||||
27 27 | # Should handle user brackets when fixing.
|
||||
28 28 | field9: int | (int | str) # PYI016: Duplicate union member `int`
|
||||
|
@ -209,7 +209,7 @@ PYI016.pyi:32:21: PYI016 [*] Duplicate union member `int`
|
|||
|
|
||||
= help: Remove duplicate union member `int`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
29 29 | field10: (str | int) | str # PYI016: Duplicate union member `str`
|
||||
30 30 |
|
||||
31 31 | # Should emit for nested unions.
|
||||
|
|
|
@ -12,7 +12,7 @@ PYI020.pyi:7:10: PYI020 [*] Quoted annotations should not be included in stubs
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
4 4 |
|
||||
5 5 | import typing_extensions
|
||||
6 6 |
|
||||
|
@ -31,7 +31,7 @@ PYI020.pyi:8:15: PYI020 [*] Quoted annotations should not be included in stubs
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
5 5 | import typing_extensions
|
||||
6 6 |
|
||||
7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs
|
||||
|
@ -52,7 +52,7 @@ PYI020.pyi:9:26: PYI020 [*] Quoted annotations should not be included in stubs
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
6 6 |
|
||||
7 7 | def f(x: "int"): ... # Y020 Quoted annotations should never be used in stubs
|
||||
8 8 | def g(x: list["int"]): ... # Y020 Quoted annotations should never be used in stubs
|
||||
|
@ -72,7 +72,7 @@ PYI020.pyi:13:12: PYI020 [*] Quoted annotations should not be included in stubs
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
10 10 |
|
||||
11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ...
|
||||
12 12 |
|
||||
|
@ -92,7 +92,7 @@ PYI020.pyi:14:25: PYI020 [*] Quoted annotations should not be included in stubs
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
11 11 | def h(w: Literal["a", "b"], x: typing.Literal["c"], y: typing_extensions.Literal["d"], z: _T) -> _T: ...
|
||||
12 12 |
|
||||
13 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs
|
||||
|
@ -112,7 +112,7 @@ PYI020.pyi:16:18: PYI020 [*] Quoted annotations should not be included in stubs
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
13 13 | def j() -> "int": ... # Y020 Quoted annotations should never be used in stubs
|
||||
14 14 | Alias: TypeAlias = list["int"] # Y020 Quoted annotations should never be used in stubs
|
||||
15 15 |
|
||||
|
@ -132,7 +132,7 @@ PYI020.pyi:20:8: PYI020 [*] Quoted annotations should not be included in stubs
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
17 17 | """Documented and guaranteed useful.""" # Y021 Docstrings should not be included in stubs
|
||||
18 18 |
|
||||
19 19 | if sys.platform == "linux":
|
||||
|
@ -153,7 +153,7 @@ PYI020.pyi:22:8: PYI020 [*] Quoted annotations should not be included in stubs
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
19 19 | if sys.platform == "linux":
|
||||
20 20 | f: "int" # Y020 Quoted annotations should never be used in stubs
|
||||
21 21 | elif sys.platform == "win32":
|
||||
|
@ -174,7 +174,7 @@ PYI020.pyi:24:8: PYI020 [*] Quoted annotations should not be included in stubs
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
21 21 | elif sys.platform == "win32":
|
||||
22 22 | f: "str" # Y020 Quoted annotations should never be used in stubs
|
||||
23 23 | else:
|
||||
|
|
|
@ -35,8 +35,7 @@ pub(crate) fn unnecessary_paren_on_raise_exception(checker: &mut Checker, expr:
|
|||
.expect("Expected call to include parentheses");
|
||||
let mut diagnostic = Diagnostic::new(UnnecessaryParenOnRaiseException, range);
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::deletion(func.end(), range.end())));
|
||||
diagnostic.set_fix(Fix::automatic(Edit::deletion(func.end(), range.end())));
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ RSE102.py:5:21: RSE102 [*] Unnecessary parentheses on raised exception
|
|||
|
|
||||
= help: Remove unnecessary parentheses
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
2 2 | y = 6 + "7"
|
||||
3 3 | except TypeError:
|
||||
4 4 | # RSE102
|
||||
|
@ -32,7 +32,7 @@ RSE102.py:13:16: RSE102 [*] Unnecessary parentheses on raised exception
|
|||
|
|
||||
= help: Remove unnecessary parentheses
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
10 10 | raise
|
||||
11 11 |
|
||||
12 12 | # RSE102
|
||||
|
@ -52,7 +52,7 @@ RSE102.py:16:17: RSE102 [*] Unnecessary parentheses on raised exception
|
|||
|
|
||||
= help: Remove unnecessary parentheses
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
13 13 | raise TypeError()
|
||||
14 14 |
|
||||
15 15 | # RSE102
|
||||
|
@ -73,7 +73,7 @@ RSE102.py:20:5: RSE102 [*] Unnecessary parentheses on raised exception
|
|||
|
|
||||
= help: Remove unnecessary parentheses
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
16 16 | raise TypeError ()
|
||||
17 17 |
|
||||
18 18 | # RSE102
|
||||
|
@ -97,7 +97,7 @@ RSE102.py:23:16: RSE102 [*] Unnecessary parentheses on raised exception
|
|||
|
|
||||
= help: Remove unnecessary parentheses
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
20 20 | ()
|
||||
21 21 |
|
||||
22 22 | # RSE102
|
||||
|
@ -122,7 +122,7 @@ RSE102.py:28:16: RSE102 [*] Unnecessary parentheses on raised exception
|
|||
|
|
||||
= help: Remove unnecessary parentheses
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
25 25 | )
|
||||
26 26 |
|
||||
27 27 | # RSE102
|
||||
|
|
|
@ -102,8 +102,7 @@ pub(crate) fn convert_for_loop_to_any_all(
|
|||
TextRange::new(stmt.start(), loop_info.terminal),
|
||||
);
|
||||
if checker.patch(diagnostic.kind.rule()) && checker.semantic().is_builtin("any") {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::replacement(
|
||||
diagnostic.set_fix(Fix::suggested(Edit::replacement(
|
||||
contents,
|
||||
stmt.start(),
|
||||
loop_info.terminal,
|
||||
|
@ -193,8 +192,7 @@ pub(crate) fn convert_for_loop_to_any_all(
|
|||
TextRange::new(stmt.start(), loop_info.terminal),
|
||||
);
|
||||
if checker.patch(diagnostic.kind.rule()) && checker.semantic().is_builtin("all") {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::replacement(
|
||||
diagnostic.set_fix(Fix::suggested(Edit::replacement(
|
||||
contents,
|
||||
stmt.start(),
|
||||
loop_info.terminal,
|
||||
|
|
|
@ -182,8 +182,7 @@ pub(crate) fn yoda_conditions(
|
|||
expr.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(
|
||||
suggestion,
|
||||
expr.range(),
|
||||
)));
|
||||
|
|
|
@ -11,7 +11,7 @@ SIM300.py:2:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda
|
|||
|
|
||||
= help: Replace Yoda condition with `compare == "yoda"`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | # Errors
|
||||
2 |-"yoda" == compare # SIM300
|
||||
2 |+compare == "yoda" # SIM300
|
||||
|
@ -30,7 +30,7 @@ SIM300.py:3:1: SIM300 [*] Yoda conditions are discouraged, use `compare == "yoda
|
|||
|
|
||||
= help: Replace Yoda condition with `compare == "yoda"`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | # Errors
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 |-"yoda" == compare # SIM300
|
||||
|
@ -50,7 +50,7 @@ SIM300.py:4:1: SIM300 [*] Yoda conditions are discouraged, use `age == 42` inste
|
|||
|
|
||||
= help: Replace Yoda condition with `age == 42`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | # Errors
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 3 | "yoda" == compare # SIM300
|
||||
|
@ -71,7 +71,7 @@ SIM300.py:5:1: SIM300 [*] Yoda conditions are discouraged, use `compare == ("a",
|
|||
|
|
||||
= help: Replace Yoda condition with `compare == ("a", "b")`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
2 2 | "yoda" == compare # SIM300
|
||||
3 3 | "yoda" == compare # SIM300
|
||||
4 4 | 42 == age # SIM300
|
||||
|
@ -92,7 +92,7 @@ SIM300.py:6:1: SIM300 [*] Yoda conditions are discouraged, use `compare >= "yoda
|
|||
|
|
||||
= help: Replace Yoda condition with `compare >= "yoda"`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 | "yoda" == compare # SIM300
|
||||
4 4 | 42 == age # SIM300
|
||||
5 5 | ("a", "b") == compare # SIM300
|
||||
|
@ -113,7 +113,7 @@ SIM300.py:7:1: SIM300 [*] Yoda conditions are discouraged, use `compare > "yoda"
|
|||
|
|
||||
= help: Replace Yoda condition with `compare > "yoda"`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
4 4 | 42 == age # SIM300
|
||||
5 5 | ("a", "b") == compare # SIM300
|
||||
6 6 | "yoda" <= compare # SIM300
|
||||
|
@ -134,7 +134,7 @@ SIM300.py:8:1: SIM300 [*] Yoda conditions are discouraged, use `age < 42` instea
|
|||
|
|
||||
= help: Replace Yoda condition with `age < 42`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
5 5 | ("a", "b") == compare # SIM300
|
||||
6 6 | "yoda" <= compare # SIM300
|
||||
7 7 | "yoda" < compare # SIM300
|
||||
|
@ -155,7 +155,7 @@ SIM300.py:9:1: SIM300 [*] Yoda conditions are discouraged, use `age < -42` inste
|
|||
|
|
||||
= help: Replace Yoda condition with `age < -42`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
6 6 | "yoda" <= compare # SIM300
|
||||
7 7 | "yoda" < compare # SIM300
|
||||
8 8 | 42 > age # SIM300
|
||||
|
@ -176,7 +176,7 @@ SIM300.py:10:1: SIM300 [*] Yoda conditions are discouraged, use `age < +42` inst
|
|||
|
|
||||
= help: Replace Yoda condition with `age < +42`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
7 7 | "yoda" < compare # SIM300
|
||||
8 8 | 42 > age # SIM300
|
||||
9 9 | -42 > age # SIM300
|
||||
|
@ -197,7 +197,7 @@ SIM300.py:11:1: SIM300 [*] Yoda conditions are discouraged, use `age == YODA` in
|
|||
|
|
||||
= help: Replace Yoda condition with `age == YODA`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
8 8 | 42 > age # SIM300
|
||||
9 9 | -42 > age # SIM300
|
||||
10 10 | +42 > age # SIM300
|
||||
|
@ -218,7 +218,7 @@ SIM300.py:12:1: SIM300 [*] Yoda conditions are discouraged, use `age < YODA` ins
|
|||
|
|
||||
= help: Replace Yoda condition with `age < YODA`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
9 9 | -42 > age # SIM300
|
||||
10 10 | +42 > age # SIM300
|
||||
11 11 | YODA == age # SIM300
|
||||
|
@ -239,7 +239,7 @@ SIM300.py:13:1: SIM300 [*] Yoda conditions are discouraged, use `age <= YODA` in
|
|||
|
|
||||
= help: Replace Yoda condition with `age <= YODA`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
10 10 | +42 > age # SIM300
|
||||
11 11 | YODA == age # SIM300
|
||||
12 12 | YODA > age # SIM300
|
||||
|
@ -260,7 +260,7 @@ SIM300.py:14:1: SIM300 [*] Yoda conditions are discouraged, use `age == JediOrde
|
|||
|
|
||||
= help: Replace Yoda condition with `age == JediOrder.YODA`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
11 11 | YODA == age # SIM300
|
||||
12 12 | YODA > age # SIM300
|
||||
13 13 | YODA >= age # SIM300
|
||||
|
@ -280,7 +280,7 @@ SIM300.py:15:1: SIM300 [*] Yoda conditions are discouraged, use `(number - 100)
|
|||
|
|
||||
= help: Replace Yoda condition with `(number - 100) > 0`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
12 12 | YODA > age # SIM300
|
||||
13 13 | YODA >= age # SIM300
|
||||
14 14 | JediOrder.YODA == age # SIM300
|
||||
|
@ -301,7 +301,7 @@ SIM300.py:16:1: SIM300 [*] Yoda conditions are discouraged, use `(60 * 60) < Som
|
|||
|
|
||||
= help: Replace Yoda condition with `(60 * 60) < SomeClass().settings.SOME_CONSTANT_VALUE`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
13 13 | YODA >= age # SIM300
|
||||
14 14 | JediOrder.YODA == age # SIM300
|
||||
15 15 | 0 < (number - 100) # SIM300
|
||||
|
|
|
@ -72,8 +72,7 @@ pub(crate) fn deprecated_type_alias(checker: &mut Checker, expr: &Expr) {
|
|||
expr.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(
|
||||
match type_name {
|
||||
"unicode" => "str",
|
||||
"long" => "int",
|
||||
|
|
|
@ -103,8 +103,7 @@ pub(crate) fn lambda_assignment(
|
|||
indented.push_str(&line);
|
||||
}
|
||||
}
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::suggested(Edit::range_replacement(
|
||||
indented,
|
||||
stmt.range(),
|
||||
)));
|
||||
|
|
|
@ -295,8 +295,7 @@ pub(crate) fn literal_comparisons(
|
|||
.collect::<Vec<_>>();
|
||||
let content = compare(left, &ops, comparators, checker.generator());
|
||||
for diagnostic in &mut diagnostics {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::suggested(Edit::range_replacement(
|
||||
content.to_string(),
|
||||
expr.range(),
|
||||
)));
|
||||
|
|
|
@ -99,8 +99,7 @@ pub(crate) fn not_tests(
|
|||
if check_not_in {
|
||||
let mut diagnostic = Diagnostic::new(NotInTest, operand.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(
|
||||
compare(
|
||||
left,
|
||||
&[Cmpop::NotIn],
|
||||
|
@ -117,8 +116,7 @@ pub(crate) fn not_tests(
|
|||
if check_not_is {
|
||||
let mut diagnostic = Diagnostic::new(NotIsTest, operand.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(
|
||||
compare(
|
||||
left,
|
||||
&[Cmpop::IsNot],
|
||||
|
|
|
@ -11,7 +11,7 @@ E713.py:2:8: E713 [*] Test for membership should be `not in`
|
|||
|
|
||||
= help: Convert to `not in`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #: E713
|
||||
2 |-if not X in Y:
|
||||
2 |+if X not in Y:
|
||||
|
@ -30,7 +30,7 @@ E713.py:5:8: E713 [*] Test for membership should be `not in`
|
|||
|
|
||||
= help: Convert to `not in`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
2 2 | if not X in Y:
|
||||
3 3 | pass
|
||||
4 4 | #: E713
|
||||
|
@ -51,7 +51,7 @@ E713.py:8:8: E713 [*] Test for membership should be `not in`
|
|||
|
|
||||
= help: Convert to `not in`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
5 5 | if not X.B in Y:
|
||||
6 6 | pass
|
||||
7 7 | #: E713
|
||||
|
@ -72,7 +72,7 @@ E713.py:11:23: E713 [*] Test for membership should be `not in`
|
|||
|
|
||||
= help: Convert to `not in`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
8 8 | if not X in Y and Z == "zero":
|
||||
9 9 | pass
|
||||
10 10 | #: E713
|
||||
|
@ -92,7 +92,7 @@ E713.py:14:9: E713 [*] Test for membership should be `not in`
|
|||
|
|
||||
= help: Convert to `not in`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
11 11 | if X == "zero" or not Y in Z:
|
||||
12 12 | pass
|
||||
13 13 | #: E713
|
||||
|
|
|
@ -11,7 +11,7 @@ E714.py:2:8: E714 [*] Test for object identity should be `is not`
|
|||
|
|
||||
= help: Convert to `is not`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #: E714
|
||||
2 |-if not X is Y:
|
||||
2 |+if X is not Y:
|
||||
|
@ -29,7 +29,7 @@ E714.py:5:8: E714 [*] Test for object identity should be `is not`
|
|||
|
|
||||
= help: Convert to `is not`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
2 2 | if not X is Y:
|
||||
3 3 | pass
|
||||
4 4 | #: E714
|
||||
|
|
|
@ -12,7 +12,7 @@ constant_literals.py:4:4: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | ###
|
||||
2 2 | # Errors
|
||||
3 3 | ###
|
||||
|
@ -33,7 +33,7 @@ constant_literals.py:6:4: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 | ###
|
||||
4 4 | if "abc" is "def": # F632 (fix)
|
||||
5 5 | pass
|
||||
|
@ -54,7 +54,7 @@ constant_literals.py:8:4: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
5 5 | pass
|
||||
6 6 | if "abc" is None: # F632 (fix, but leaves behind unfixable E711)
|
||||
7 7 | pass
|
||||
|
@ -75,7 +75,7 @@ constant_literals.py:10:4: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
7 7 | pass
|
||||
8 8 | if None is "abc": # F632 (fix, but leaves behind unfixable E711)
|
||||
9 9 | pass
|
||||
|
@ -96,7 +96,7 @@ constant_literals.py:12:4: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
9 9 | pass
|
||||
10 10 | if "abc" is False: # F632 (fix, but leaves behind unfixable E712)
|
||||
11 11 | pass
|
||||
|
|
|
@ -96,8 +96,7 @@ pub(crate) fn invalid_literal_comparison(
|
|||
None
|
||||
}
|
||||
} {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
content,
|
||||
located_op.range + expr.start(),
|
||||
)));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustpython_parser::ast::{self, Expr, Ranged};
|
||||
|
||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
||||
use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -37,14 +37,16 @@ use crate::registry::AsRule;
|
|||
#[violation]
|
||||
pub struct RaiseNotImplemented;
|
||||
|
||||
impl AlwaysAutofixableViolation for RaiseNotImplemented {
|
||||
impl Violation for RaiseNotImplemented {
|
||||
const AUTOFIX: AutofixKind = AutofixKind::Sometimes;
|
||||
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
format!("`raise NotImplemented` should be `raise NotImplementedError`")
|
||||
}
|
||||
|
||||
fn autofix_title(&self) -> String {
|
||||
"Use `raise NotImplementedError`".to_string()
|
||||
fn autofix_title(&self) -> Option<String> {
|
||||
Some("Use `raise NotImplementedError`".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,11 +76,12 @@ pub(crate) fn raise_not_implemented(checker: &mut Checker, expr: &Expr) {
|
|||
};
|
||||
let mut diagnostic = Diagnostic::new(RaiseNotImplemented, expr.range());
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
"NotImplementedError".to_string(),
|
||||
expr.range(),
|
||||
)));
|
||||
if checker.semantic().is_builtin("NotImplementedError") {
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
"NotImplementedError".to_string(),
|
||||
expr.range(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
}
|
||||
|
|
|
@ -168,8 +168,7 @@ pub(crate) fn repeated_keys(checker: &mut Checker, keys: &[Option<Expr>], values
|
|||
);
|
||||
if is_duplicate_value {
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::deletion(
|
||||
diagnostic.set_fix(Fix::suggested(Edit::deletion(
|
||||
values[i - 1].end(),
|
||||
values[i].end(),
|
||||
)));
|
||||
|
@ -193,8 +192,7 @@ pub(crate) fn repeated_keys(checker: &mut Checker, keys: &[Option<Expr>], values
|
|||
);
|
||||
if is_duplicate_value {
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::deletion(
|
||||
diagnostic.set_fix(Fix::suggested(Edit::deletion(
|
||||
values[i - 1].end(),
|
||||
values[i].end(),
|
||||
)));
|
||||
|
|
|
@ -9,7 +9,7 @@ F632.py:1:4: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 |-if x is "abc":
|
||||
1 |+if x == "abc":
|
||||
2 2 | pass
|
||||
|
@ -26,7 +26,7 @@ F632.py:4:4: F632 [*] Use `!=` to compare constant literals
|
|||
|
|
||||
= help: Replace `is not` with `!=`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | if x is "abc":
|
||||
2 2 | pass
|
||||
3 3 |
|
||||
|
@ -48,7 +48,7 @@ F632.py:7:4: F632 [*] Use `!=` to compare constant literals
|
|||
|
|
||||
= help: Replace `is not` with `!=`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
4 4 | if 123 is not y:
|
||||
5 5 | pass
|
||||
6 6 |
|
||||
|
@ -69,7 +69,7 @@ F632.py:11:4: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
8 8 | not y:
|
||||
9 9 | pass
|
||||
10 10 |
|
||||
|
@ -89,7 +89,7 @@ F632.py:14:4: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
11 11 | if "123" is x < 3:
|
||||
12 12 | pass
|
||||
13 13 |
|
||||
|
@ -109,7 +109,7 @@ F632.py:17:4: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
14 14 | if "123" != x is 3:
|
||||
15 15 | pass
|
||||
16 16 |
|
||||
|
@ -129,7 +129,7 @@ F632.py:20:14: F632 [*] Use `==` to compare constant literals
|
|||
|
|
||||
= help: Replace `is` with `==`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
17 17 | if ("123" != x) is 3:
|
||||
18 18 | pass
|
||||
19 19 |
|
||||
|
@ -152,7 +152,7 @@ F632.py:23:2: F632 [*] Use `!=` to compare constant literals
|
|||
|
|
||||
= help: Replace `is not` with `!=`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
20 20 | if "123" != (x is 3):
|
||||
21 21 | pass
|
||||
22 22 |
|
||||
|
@ -174,7 +174,7 @@ F632.py:26:2: F632 [*] Use `!=` to compare constant literals
|
|||
|
|
||||
= help: Replace `is not` with `!=`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
23 23 | {2 is
|
||||
24 24 | not ''}
|
||||
25 25 |
|
||||
|
|
|
@ -9,7 +9,7 @@ F901.py:2:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedErr
|
|||
|
|
||||
= help: Use `raise NotImplementedError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | def f() -> None:
|
||||
2 |- raise NotImplemented()
|
||||
2 |+ raise NotImplementedError()
|
||||
|
@ -25,7 +25,7 @@ F901.py:6:11: F901 [*] `raise NotImplemented` should be `raise NotImplementedErr
|
|||
|
|
||||
= help: Use `raise NotImplementedError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 |
|
||||
4 4 |
|
||||
5 5 | def g() -> None:
|
||||
|
|
|
@ -83,8 +83,7 @@ pub(crate) fn manual_from_import(
|
|||
level: Some(Int::new(0)),
|
||||
range: TextRange::default(),
|
||||
};
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
checker.generator().stmt(&node.into()),
|
||||
stmt.range(),
|
||||
)));
|
||||
|
|
|
@ -12,7 +12,7 @@ import_aliasing.py:9:8: PLR0402 [*] Use `from os import path` in lieu of alias
|
|||
|
|
||||
= help: Replace with `from os import path`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
6 6 | import collections as collections # [useless-import-alias]
|
||||
7 7 | from collections import OrderedDict as OrderedDict # [useless-import-alias]
|
||||
8 8 | from collections import OrderedDict as o_dict
|
||||
|
@ -33,7 +33,7 @@ import_aliasing.py:11:8: PLR0402 [*] Use `from foo.bar import foobar` in lieu of
|
|||
|
|
||||
= help: Replace with `from foo.bar import foobar`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
8 8 | from collections import OrderedDict as o_dict
|
||||
9 9 | import os.path as path # [consider-using-from-import]
|
||||
10 10 | import os.path as p
|
||||
|
|
|
@ -99,8 +99,7 @@ pub(crate) fn deprecated_unittest_alias(checker: &mut Checker, expr: &Expr) {
|
|||
expr.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(
|
||||
format!("self.{target}"),
|
||||
expr.range(),
|
||||
)));
|
||||
|
|
|
@ -348,8 +348,7 @@ pub(crate) fn f_strings(checker: &mut Checker, summary: &FormatSummary, expr: &E
|
|||
|
||||
let mut diagnostic = Diagnostic::new(FString, expr.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(
|
||||
contents,
|
||||
expr.range(),
|
||||
)));
|
||||
|
|
|
@ -88,11 +88,12 @@ fn atom_diagnostic(checker: &mut Checker, target: &Expr) {
|
|||
target.range(),
|
||||
);
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
"OSError".to_string(),
|
||||
target.range(),
|
||||
)));
|
||||
if checker.semantic().is_builtin("OSError") {
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
"OSError".to_string(),
|
||||
target.range(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
}
|
||||
|
@ -101,49 +102,49 @@ fn atom_diagnostic(checker: &mut Checker, target: &Expr) {
|
|||
fn tuple_diagnostic(checker: &mut Checker, target: &Expr, aliases: &[&Expr]) {
|
||||
let mut diagnostic = Diagnostic::new(OSErrorAlias { name: None }, target.range());
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
let Expr::Tuple(ast::ExprTuple { elts, ..}) = target else {
|
||||
panic!("Expected Expr::Tuple");
|
||||
};
|
||||
|
||||
// Filter out any `OSErrors` aliases.
|
||||
let mut remaining: Vec<Expr> = elts
|
||||
.iter()
|
||||
.filter_map(|elt| {
|
||||
if aliases.contains(&elt) {
|
||||
None
|
||||
} else {
|
||||
Some(elt.clone())
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
// If `OSError` itself isn't already in the tuple, add it.
|
||||
if elts.iter().all(|elt| !is_os_error(elt, checker.semantic())) {
|
||||
let node = ast::ExprName {
|
||||
id: "OSError".into(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
if checker.semantic().is_builtin("OSError") {
|
||||
let Expr::Tuple(ast::ExprTuple { elts, .. }) = target else {
|
||||
panic!("Expected Expr::Tuple");
|
||||
};
|
||||
remaining.insert(0, node.into());
|
||||
}
|
||||
|
||||
if remaining.len() == 1 {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
"OSError".to_string(),
|
||||
target.range(),
|
||||
)));
|
||||
} else {
|
||||
let node = ast::ExprTuple {
|
||||
elts: remaining,
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
};
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
format!("({})", checker.generator().expr(&node.into())),
|
||||
target.range(),
|
||||
)));
|
||||
// Filter out any `OSErrors` aliases.
|
||||
let mut remaining: Vec<Expr> = elts
|
||||
.iter()
|
||||
.filter_map(|elt| {
|
||||
if aliases.contains(&elt) {
|
||||
None
|
||||
} else {
|
||||
Some(elt.clone())
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
// If `OSError` itself isn't already in the tuple, add it.
|
||||
if elts.iter().all(|elt| !is_os_error(elt, checker.semantic())) {
|
||||
let node = ast::ExprName {
|
||||
id: "OSError".into(),
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
};
|
||||
remaining.insert(0, node.into());
|
||||
}
|
||||
|
||||
if remaining.len() == 1 {
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
"OSError".to_string(),
|
||||
target.range(),
|
||||
)));
|
||||
} else {
|
||||
let node = ast::ExprTuple {
|
||||
elts: remaining,
|
||||
ctx: ExprContext::Load,
|
||||
range: TextRange::default(),
|
||||
};
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
format!("({})", checker.generator().expr(&node.into())),
|
||||
target.range(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
|
|
|
@ -238,8 +238,7 @@ fn fix_py2_block(
|
|||
let end = orelse.last()?;
|
||||
if indentation(checker.locator, start).is_none() {
|
||||
// Inline `else` block (e.g., `else: x = 1`).
|
||||
#[allow(deprecated)]
|
||||
Some(Fix::unspecified(Edit::range_replacement(
|
||||
Some(Fix::suggested(Edit::range_replacement(
|
||||
checker
|
||||
.locator
|
||||
.slice(TextRange::new(start.start(), end.end()))
|
||||
|
@ -258,8 +257,7 @@ fn fix_py2_block(
|
|||
.ok()
|
||||
})
|
||||
.map(|contents| {
|
||||
#[allow(deprecated)]
|
||||
Fix::unspecified(Edit::replacement(
|
||||
Fix::suggested(Edit::replacement(
|
||||
contents,
|
||||
checker.locator.line_start(stmt.start()),
|
||||
stmt.end(),
|
||||
|
@ -271,21 +269,13 @@ fn fix_py2_block(
|
|||
// If we have an `if` and an `elif`, turn the `elif` into an `if`.
|
||||
let start_location = leading_token.range.start();
|
||||
let end_location = trailing_token.range.start() + TextSize::from(2);
|
||||
#[allow(deprecated)]
|
||||
Some(Fix::unspecified(Edit::deletion(
|
||||
start_location,
|
||||
end_location,
|
||||
)))
|
||||
Some(Fix::suggested(Edit::deletion(start_location, end_location)))
|
||||
}
|
||||
(StartTok::Elif, _) => {
|
||||
// If we have an `elif`, delete up to the `else` or the end of the statement.
|
||||
let start_location = leading_token.range.start();
|
||||
let end_location = trailing_token.range.start();
|
||||
#[allow(deprecated)]
|
||||
Some(Fix::unspecified(Edit::deletion(
|
||||
start_location,
|
||||
end_location,
|
||||
)))
|
||||
Some(Fix::suggested(Edit::deletion(start_location, end_location)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,8 +296,7 @@ fn fix_py3_block(
|
|||
let end = body.last()?;
|
||||
if indentation(checker.locator, start).is_none() {
|
||||
// Inline `if` block (e.g., `if ...: x = 1`).
|
||||
#[allow(deprecated)]
|
||||
Some(Fix::unspecified(Edit::range_replacement(
|
||||
Some(Fix::suggested(Edit::range_replacement(
|
||||
checker
|
||||
.locator
|
||||
.slice(TextRange::new(start.start(), end.end()))
|
||||
|
@ -326,8 +315,7 @@ fn fix_py3_block(
|
|||
.ok()
|
||||
})
|
||||
.map(|contents| {
|
||||
#[allow(deprecated)]
|
||||
Fix::unspecified(Edit::replacement(
|
||||
Fix::suggested(Edit::replacement(
|
||||
contents,
|
||||
checker.locator.line_start(stmt.start()),
|
||||
stmt.end(),
|
||||
|
@ -340,8 +328,7 @@ fn fix_py3_block(
|
|||
// the rest.
|
||||
let end = body.last()?;
|
||||
let text = checker.locator.slice(TextRange::new(test.end(), end.end()));
|
||||
#[allow(deprecated)]
|
||||
Some(Fix::unspecified(Edit::range_replacement(
|
||||
Some(Fix::suggested(Edit::range_replacement(
|
||||
format!("else{text}"),
|
||||
stmt.range(),
|
||||
)))
|
||||
|
|
|
@ -54,8 +54,7 @@ impl AlwaysAutofixableViolation for QuotedAnnotation {
|
|||
pub(crate) fn quoted_annotation(checker: &mut Checker, annotation: &str, range: TextRange) {
|
||||
let mut diagnostic = Diagnostic::new(QuotedAnnotation, range);
|
||||
if checker.patch(Rule::QuotedAnnotation) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
annotation.to_string(),
|
||||
range,
|
||||
)));
|
||||
|
|
|
@ -138,14 +138,14 @@ fn create_check(
|
|||
);
|
||||
if patch {
|
||||
if let Some(content) = replacement_value {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
content.to_string(),
|
||||
mode_param.range(),
|
||||
)));
|
||||
} else {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.try_set_fix_from_edit(|| create_remove_param_fix(locator, expr, mode_param));
|
||||
diagnostic.try_set_fix(|| {
|
||||
create_remove_param_fix(locator, expr, mode_param).map(Fix::automatic)
|
||||
});
|
||||
}
|
||||
}
|
||||
diagnostic
|
||||
|
|
|
@ -58,12 +58,13 @@ pub(crate) fn replace_universal_newlines(checker: &mut Checker, func: &Expr, kwa
|
|||
matches!(call_path.as_slice(), ["subprocess", "run"])
|
||||
})
|
||||
{
|
||||
let Some(kwarg) = find_keyword(kwargs, "universal_newlines") else { return; };
|
||||
let Some(kwarg) = find_keyword(kwargs, "universal_newlines") else {
|
||||
return;
|
||||
};
|
||||
let range = TextRange::at(kwarg.start(), "universal_newlines".text_len());
|
||||
let mut diagnostic = Diagnostic::new(ReplaceUniversalNewlines, 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(
|
||||
"text".to_string(),
|
||||
range,
|
||||
)));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use rustpython_parser::ast::{self, Expr, Ranged};
|
||||
|
||||
use ruff_diagnostics::{AlwaysAutofixableViolation, Diagnostic, Edit, Fix};
|
||||
use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation};
|
||||
use ruff_macros::{derive_message_formats, violation};
|
||||
|
||||
use crate::checkers::ast::Checker;
|
||||
|
@ -34,16 +34,21 @@ pub struct TypeOfPrimitive {
|
|||
primitive: Primitive,
|
||||
}
|
||||
|
||||
impl AlwaysAutofixableViolation for TypeOfPrimitive {
|
||||
impl Violation for TypeOfPrimitive {
|
||||
const AUTOFIX: AutofixKind = AutofixKind::Sometimes;
|
||||
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
let TypeOfPrimitive { primitive } = self;
|
||||
format!("Use `{}` instead of `type(...)`", primitive.builtin())
|
||||
}
|
||||
|
||||
fn autofix_title(&self) -> String {
|
||||
fn autofix_title(&self) -> Option<String> {
|
||||
let TypeOfPrimitive { primitive } = self;
|
||||
format!("Replace `type(...)` with `{}`", primitive.builtin())
|
||||
Some(format!(
|
||||
"Replace `type(...)` with `{}`",
|
||||
primitive.builtin()
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,11 +74,13 @@ pub(crate) fn type_of_primitive(checker: &mut Checker, expr: &Expr, func: &Expr,
|
|||
};
|
||||
let mut diagnostic = Diagnostic::new(TypeOfPrimitive { primitive }, expr.range());
|
||||
if checker.patch(diagnostic.kind.rule()) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
primitive.builtin(),
|
||||
expr.range(),
|
||||
)));
|
||||
let builtin = primitive.builtin();
|
||||
if checker.semantic().is_builtin(&builtin) {
|
||||
diagnostic.set_fix(Fix::automatic(Edit::range_replacement(
|
||||
primitive.builtin(),
|
||||
expr.range(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@ pub(crate) fn unnecessary_coding_comment(line: &Line, autofix: bool) -> Option<D
|
|||
if CODING_COMMENT_REGEX.is_match(line.as_str()) {
|
||||
let mut diagnostic = Diagnostic::new(UTF8EncodingDeclaration, line.full_range());
|
||||
if autofix {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::deletion(
|
||||
diagnostic.set_fix(Fix::automatic(Edit::deletion(
|
||||
line.start(),
|
||||
line.full_end(),
|
||||
)));
|
||||
|
|
|
@ -143,8 +143,8 @@ fn replace_with_bytes_literal(locator: &Locator, expr: &Expr) -> Fix {
|
|||
}
|
||||
prev = range.end();
|
||||
}
|
||||
#[allow(deprecated)]
|
||||
Fix::unspecified(Edit::range_replacement(replacement, expr.range()))
|
||||
|
||||
Fix::automatic(Edit::range_replacement(replacement, expr.range()))
|
||||
}
|
||||
|
||||
/// UP012
|
||||
|
@ -187,8 +187,7 @@ pub(crate) fn unnecessary_encode_utf8(
|
|||
expr.range(),
|
||||
);
|
||||
if checker.patch(Rule::UnnecessaryEncodeUTF8) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.try_set_fix_from_edit(|| {
|
||||
diagnostic.try_set_fix(|| {
|
||||
remove_argument(
|
||||
checker.locator,
|
||||
func.start(),
|
||||
|
@ -197,6 +196,7 @@ pub(crate) fn unnecessary_encode_utf8(
|
|||
kwargs,
|
||||
false,
|
||||
)
|
||||
.map(Fix::automatic)
|
||||
});
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
|
@ -209,8 +209,7 @@ pub(crate) fn unnecessary_encode_utf8(
|
|||
expr.range(),
|
||||
);
|
||||
if checker.patch(Rule::UnnecessaryEncodeUTF8) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.try_set_fix_from_edit(|| {
|
||||
diagnostic.try_set_fix(|| {
|
||||
remove_argument(
|
||||
checker.locator,
|
||||
func.start(),
|
||||
|
@ -219,6 +218,7 @@ pub(crate) fn unnecessary_encode_utf8(
|
|||
kwargs,
|
||||
false,
|
||||
)
|
||||
.map(Fix::automatic)
|
||||
});
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
|
@ -238,8 +238,7 @@ pub(crate) fn unnecessary_encode_utf8(
|
|||
expr.range(),
|
||||
);
|
||||
if checker.patch(Rule::UnnecessaryEncodeUTF8) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.try_set_fix_from_edit(|| {
|
||||
diagnostic.try_set_fix(|| {
|
||||
remove_argument(
|
||||
checker.locator,
|
||||
func.start(),
|
||||
|
@ -248,6 +247,7 @@ pub(crate) fn unnecessary_encode_utf8(
|
|||
kwargs,
|
||||
false,
|
||||
)
|
||||
.map(Fix::automatic)
|
||||
});
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
|
@ -260,8 +260,7 @@ pub(crate) fn unnecessary_encode_utf8(
|
|||
expr.range(),
|
||||
);
|
||||
if checker.patch(Rule::UnnecessaryEncodeUTF8) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.try_set_fix_from_edit(|| {
|
||||
diagnostic.try_set_fix(|| {
|
||||
remove_argument(
|
||||
checker.locator,
|
||||
func.start(),
|
||||
|
@ -270,6 +269,7 @@ pub(crate) fn unnecessary_encode_utf8(
|
|||
kwargs,
|
||||
false,
|
||||
)
|
||||
.map(Fix::automatic)
|
||||
});
|
||||
}
|
||||
checker.diagnostics.push(diagnostic);
|
||||
|
|
|
@ -190,8 +190,7 @@ pub(crate) fn yield_in_for_loop(checker: &mut Checker, stmt: &Stmt) {
|
|||
if checker.patch(diagnostic.kind.rule()) {
|
||||
let contents = checker.locator.slice(item.iter.range());
|
||||
let contents = format!("yield from {contents}");
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::suggested(Edit::range_replacement(
|
||||
contents,
|
||||
item.stmt.range(),
|
||||
)));
|
||||
|
|
|
@ -10,7 +10,7 @@ UP003.py:1:1: UP003 [*] Use `str` instead of `type(...)`
|
|||
|
|
||||
= help: Replace `type(...)` with `str`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 |-type("")
|
||||
1 |+str
|
||||
2 2 | type(b"")
|
||||
|
@ -27,7 +27,7 @@ UP003.py:2:1: UP003 [*] Use `bytes` instead of `type(...)`
|
|||
|
|
||||
= help: Replace `type(...)` with `bytes`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | type("")
|
||||
2 |-type(b"")
|
||||
2 |+bytes
|
||||
|
@ -46,7 +46,7 @@ UP003.py:3:1: UP003 [*] Use `int` instead of `type(...)`
|
|||
|
|
||||
= help: Replace `type(...)` with `int`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | type("")
|
||||
2 2 | type(b"")
|
||||
3 |-type(0)
|
||||
|
@ -65,7 +65,7 @@ UP003.py:4:1: UP003 [*] Use `float` instead of `type(...)`
|
|||
|
|
||||
= help: Replace `type(...)` with `float`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | type("")
|
||||
2 2 | type(b"")
|
||||
3 3 | type(0)
|
||||
|
@ -86,7 +86,7 @@ UP003.py:5:1: UP003 [*] Use `complex` instead of `type(...)`
|
|||
|
|
||||
= help: Replace `type(...)` with `complex`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
2 2 | type(b"")
|
||||
3 3 | type(0)
|
||||
4 4 | type(0.0)
|
||||
|
|
|
@ -10,7 +10,7 @@ UP009_0.py:1:1: UP009 [*] UTF-8 encoding declaration is unnecessary
|
|||
|
|
||||
= help: Remove unnecessary coding comment
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 |-# coding=utf8
|
||||
2 1 |
|
||||
3 2 | print("Hello world")
|
||||
|
|
|
@ -11,7 +11,7 @@ UP009_1.py:2:1: UP009 [*] UTF-8 encoding declaration is unnecessary
|
|||
|
|
||||
= help: Remove unnecessary coding comment
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | #!/usr/bin/python
|
||||
2 |-# -*- coding: utf-8 -*-
|
||||
3 2 |
|
||||
|
|
|
@ -11,7 +11,7 @@ UP012.py:2:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | # ASCII literals should be replaced by a bytes literal
|
||||
2 |-"foo".encode("utf-8") # b"foo"
|
||||
2 |+b"foo" # b"foo"
|
||||
|
@ -30,7 +30,7 @@ UP012.py:3:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | # ASCII literals should be replaced by a bytes literal
|
||||
2 2 | "foo".encode("utf-8") # b"foo"
|
||||
3 |-"foo".encode("u8") # b"foo"
|
||||
|
@ -50,7 +50,7 @@ UP012.py:4:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | # ASCII literals should be replaced by a bytes literal
|
||||
2 2 | "foo".encode("utf-8") # b"foo"
|
||||
3 3 | "foo".encode("u8") # b"foo"
|
||||
|
@ -71,7 +71,7 @@ UP012.py:5:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
2 2 | "foo".encode("utf-8") # b"foo"
|
||||
3 3 | "foo".encode("u8") # b"foo"
|
||||
4 4 | "foo".encode() # b"foo"
|
||||
|
@ -92,7 +92,7 @@ UP012.py:6:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 | "foo".encode("u8") # b"foo"
|
||||
4 4 | "foo".encode() # b"foo"
|
||||
5 5 | "foo".encode("UTF8") # b"foo"
|
||||
|
@ -113,7 +113,7 @@ UP012.py:7:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
4 4 | "foo".encode() # b"foo"
|
||||
5 5 | "foo".encode("UTF8") # b"foo"
|
||||
6 6 | U"foo".encode("utf-8") # b"foo"
|
||||
|
@ -140,7 +140,7 @@ UP012.py:8:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
5 5 | "foo".encode("UTF8") # b"foo"
|
||||
6 6 | U"foo".encode("utf-8") # b"foo"
|
||||
7 7 | "foo".encode(encoding="utf-8") # b"foo"
|
||||
|
@ -170,7 +170,7 @@ UP012.py:16:5: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
13 13 | "utf-8"
|
||||
14 14 | )
|
||||
15 15 | (
|
||||
|
@ -195,7 +195,7 @@ UP012.py:20:5: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
17 17 | "Ipsum".encode()
|
||||
18 18 | )
|
||||
19 19 | (
|
||||
|
@ -217,7 +217,7 @@ UP012.py:24:5: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
21 21 | "Ipsum".encode() # Comment
|
||||
22 22 | )
|
||||
23 23 | (
|
||||
|
@ -237,7 +237,7 @@ UP012.py:32:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Remove unnecessary encoding argument
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
29 29 | string.encode("utf-8")
|
||||
30 30 |
|
||||
31 31 | bar = "bar"
|
||||
|
@ -260,7 +260,7 @@ UP012.py:36:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Remove unnecessary encoding argument
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
33 33 | encoding = "latin"
|
||||
34 34 | "foo".encode(encoding)
|
||||
35 35 | f"foo{bar}".encode(encoding)
|
||||
|
@ -282,7 +282,7 @@ UP012.py:53:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Remove unnecessary encoding argument
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
50 50 | "unicode text©".encode(encoding="utf-8", errors="replace")
|
||||
51 51 |
|
||||
52 52 | # Unicode literals should only be stripped of default encoding.
|
||||
|
@ -303,7 +303,7 @@ UP012.py:55:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Remove unnecessary encoding argument
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
52 52 | # Unicode literals should only be stripped of default encoding.
|
||||
53 53 | "unicode text©".encode("utf-8") # "unicode text©".encode()
|
||||
54 54 | "unicode text©".encode()
|
||||
|
@ -324,7 +324,7 @@ UP012.py:57:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
54 54 | "unicode text©".encode()
|
||||
55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode()
|
||||
56 56 |
|
||||
|
@ -344,7 +344,7 @@ UP012.py:58:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
55 55 | "unicode text©".encode(encoding="UTF8") # "unicode text©".encode()
|
||||
56 56 |
|
||||
57 57 | r"foo\o".encode("utf-8") # br"foo\o"
|
||||
|
@ -365,7 +365,7 @@ UP012.py:59:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
56 56 |
|
||||
57 57 | r"foo\o".encode("utf-8") # br"foo\o"
|
||||
58 58 | u"foo".encode("utf-8") # b"foo"
|
||||
|
@ -385,7 +385,7 @@ UP012.py:60:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
57 57 | r"foo\o".encode("utf-8") # br"foo\o"
|
||||
58 58 | u"foo".encode("utf-8") # b"foo"
|
||||
59 59 | R"foo\o".encode("utf-8") # br"foo\o"
|
||||
|
@ -406,7 +406,7 @@ UP012.py:61:7: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
58 58 | u"foo".encode("utf-8") # b"foo"
|
||||
59 59 | R"foo\o".encode("utf-8") # br"foo\o"
|
||||
60 60 | U"foo".encode("utf-8") # b"foo"
|
||||
|
@ -429,7 +429,7 @@ UP012.py:64:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
62 62 |
|
||||
63 63 | # `encode` on parenthesized strings.
|
||||
64 64 | (
|
||||
|
@ -455,7 +455,7 @@ UP012.py:69:1: UP012 [*] Unnecessary call to `encode` as UTF-8
|
|||
|
|
||||
= help: Rewrite as bytes literal
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
67 67 | ).encode()
|
||||
68 68 |
|
||||
69 69 | ((
|
||||
|
|
|
@ -10,7 +10,7 @@ UP015.py:1:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 |-open("foo", "U")
|
||||
1 |+open("foo")
|
||||
2 2 | open("foo", "Ur")
|
||||
|
@ -27,7 +27,7 @@ UP015.py:2:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | open("foo", "U")
|
||||
2 |-open("foo", "Ur")
|
||||
2 |+open("foo")
|
||||
|
@ -46,7 +46,7 @@ UP015.py:3:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | open("foo", "U")
|
||||
2 2 | open("foo", "Ur")
|
||||
3 |-open("foo", "Ub")
|
||||
|
@ -66,7 +66,7 @@ UP015.py:4:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
1 1 | open("foo", "U")
|
||||
2 2 | open("foo", "Ur")
|
||||
3 3 | open("foo", "Ub")
|
||||
|
@ -87,7 +87,7 @@ UP015.py:5:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
2 2 | open("foo", "Ur")
|
||||
3 3 | open("foo", "Ub")
|
||||
4 4 | open("foo", "rUb")
|
||||
|
@ -108,7 +108,7 @@ UP015.py:6:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 | open("foo", "Ub")
|
||||
4 4 | open("foo", "rUb")
|
||||
5 5 | open("foo", "r")
|
||||
|
@ -128,7 +128,7 @@ UP015.py:7:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
4 4 | open("foo", "rUb")
|
||||
5 5 | open("foo", "r")
|
||||
6 6 | open("foo", "rt")
|
||||
|
@ -149,7 +149,7 @@ UP015.py:8:1: UP015 [*] Unnecessary open mode parameters, use ""w""
|
|||
|
|
||||
= help: Replace with ""w""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
5 5 | open("foo", "r")
|
||||
6 6 | open("foo", "rt")
|
||||
7 7 | open("f", "r", encoding="UTF-8")
|
||||
|
@ -170,7 +170,7 @@ UP015.py:10:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
7 7 | open("f", "r", encoding="UTF-8")
|
||||
8 8 | open("f", "wt")
|
||||
9 9 |
|
||||
|
@ -191,7 +191,7 @@ UP015.py:12:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
9 9 |
|
||||
10 10 | with open("foo", "U") as f:
|
||||
11 11 | pass
|
||||
|
@ -212,7 +212,7 @@ UP015.py:14:6: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
11 11 | pass
|
||||
12 12 | with open("foo", "Ur") as f:
|
||||
13 13 | pass
|
||||
|
@ -233,7 +233,7 @@ UP015.py:16:6: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
13 13 | pass
|
||||
14 14 | with open("foo", "Ub") as f:
|
||||
15 15 | pass
|
||||
|
@ -254,7 +254,7 @@ UP015.py:18:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
15 15 | pass
|
||||
16 16 | with open("foo", "rUb") as f:
|
||||
17 17 | pass
|
||||
|
@ -275,7 +275,7 @@ UP015.py:20:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
17 17 | pass
|
||||
18 18 | with open("foo", "r") as f:
|
||||
19 19 | pass
|
||||
|
@ -296,7 +296,7 @@ UP015.py:22:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
19 19 | pass
|
||||
20 20 | with open("foo", "rt") as f:
|
||||
21 21 | pass
|
||||
|
@ -316,7 +316,7 @@ UP015.py:24:6: UP015 [*] Unnecessary open mode parameters, use ""w""
|
|||
|
|
||||
= help: Replace with ""w""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
21 21 | pass
|
||||
22 22 | with open("foo", "r", encoding="UTF-8") as f:
|
||||
23 23 | pass
|
||||
|
@ -336,7 +336,7 @@ UP015.py:27:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
24 24 | with open("foo", "wt") as f:
|
||||
25 25 | pass
|
||||
26 26 |
|
||||
|
@ -356,7 +356,7 @@ UP015.py:28:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
25 25 | pass
|
||||
26 26 |
|
||||
27 27 | open(f("a", "b", "c"), "U")
|
||||
|
@ -377,7 +377,7 @@ UP015.py:30:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
27 27 | open(f("a", "b", "c"), "U")
|
||||
28 28 | open(f("a", "b", "c"), "Ub")
|
||||
29 29 |
|
||||
|
@ -397,7 +397,7 @@ UP015.py:32:6: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
29 29 |
|
||||
30 30 | with open(f("a", "b", "c"), "U") as f:
|
||||
31 31 | pass
|
||||
|
@ -418,7 +418,7 @@ UP015.py:35:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
32 32 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
33 33 | pass
|
||||
34 34 |
|
||||
|
@ -439,7 +439,7 @@ UP015.py:35:30: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
32 32 | with open(f("a", "b", "c"), "Ub") as f:
|
||||
33 33 | pass
|
||||
34 34 |
|
||||
|
@ -459,7 +459,7 @@ UP015.py:37:6: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
34 34 |
|
||||
35 35 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
36 36 | pass
|
||||
|
@ -479,7 +479,7 @@ UP015.py:37:31: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
34 34 |
|
||||
35 35 | with open("foo", "U") as fa, open("bar", "U") as fb:
|
||||
36 36 | pass
|
||||
|
@ -500,7 +500,7 @@ UP015.py:40:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
37 37 | with open("foo", "Ub") as fa, open("bar", "Ub") as fb:
|
||||
38 38 | pass
|
||||
39 39 |
|
||||
|
@ -519,7 +519,7 @@ UP015.py:41:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
38 38 | pass
|
||||
39 39 |
|
||||
40 40 | open("foo", mode="U")
|
||||
|
@ -540,7 +540,7 @@ UP015.py:42:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
39 39 |
|
||||
40 40 | open("foo", mode="U")
|
||||
41 41 | open(name="foo", mode="U")
|
||||
|
@ -561,7 +561,7 @@ UP015.py:44:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
41 41 | open(name="foo", mode="U")
|
||||
42 42 | open(mode="U", name="foo")
|
||||
43 43 |
|
||||
|
@ -582,7 +582,7 @@ UP015.py:46:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
43 43 |
|
||||
44 44 | with open("foo", mode="U") as f:
|
||||
45 45 | pass
|
||||
|
@ -602,7 +602,7 @@ UP015.py:48:6: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
45 45 | pass
|
||||
46 46 | with open(name="foo", mode="U") as f:
|
||||
47 47 | pass
|
||||
|
@ -623,7 +623,7 @@ UP015.py:51:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
48 48 | with open(mode="U", name="foo") as f:
|
||||
49 49 | pass
|
||||
50 50 |
|
||||
|
@ -642,7 +642,7 @@ UP015.py:52:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
49 49 | pass
|
||||
50 50 |
|
||||
51 51 | open("foo", mode="Ub")
|
||||
|
@ -663,7 +663,7 @@ UP015.py:53:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
50 50 |
|
||||
51 51 | open("foo", mode="Ub")
|
||||
52 52 | open(name="foo", mode="Ub")
|
||||
|
@ -684,7 +684,7 @@ UP015.py:55:6: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
52 52 | open(name="foo", mode="Ub")
|
||||
53 53 | open(mode="Ub", name="foo")
|
||||
54 54 |
|
||||
|
@ -705,7 +705,7 @@ UP015.py:57:6: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
54 54 |
|
||||
55 55 | with open("foo", mode="Ub") as f:
|
||||
56 56 | pass
|
||||
|
@ -725,7 +725,7 @@ UP015.py:59:6: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
56 56 | pass
|
||||
57 57 | with open(name="foo", mode="Ub") as f:
|
||||
58 58 | pass
|
||||
|
@ -746,7 +746,7 @@ UP015.py:62:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
59 59 | with open(mode="Ub", name="foo") as f:
|
||||
60 60 | pass
|
||||
61 61 |
|
||||
|
@ -766,7 +766,7 @@ UP015.py:63:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
60 60 | pass
|
||||
61 61 |
|
||||
62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
@ -786,7 +786,7 @@ UP015.py:64:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
61 61 |
|
||||
62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
63 63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
|
@ -807,7 +807,7 @@ UP015.py:65:1: UP015 [*] Unnecessary open mode parameters
|
|||
|
|
||||
= help: Remove open mode parameters
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
62 62 | open(file="foo", mode='U', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
63 63 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='U')
|
||||
64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
|
@ -828,7 +828,7 @@ UP015.py:67:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
64 64 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='U', newline=None, closefd=True, opener=None)
|
||||
65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
66 66 |
|
||||
|
@ -848,7 +848,7 @@ UP015.py:68:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
65 65 | open(mode='U', file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
66 66 |
|
||||
67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
|
@ -868,7 +868,7 @@ UP015.py:69:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
66 66 |
|
||||
67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
|
@ -889,7 +889,7 @@ UP015.py:70:1: UP015 [*] Unnecessary open mode parameters, use ""rb""
|
|||
|
|
||||
= help: Replace with ""rb""
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
67 67 | open(file="foo", mode='Ub', buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
|
||||
68 68 | open(file="foo", buffering=- 1, encoding=None, errors=None, newline=None, closefd=True, opener=None, mode='Ub')
|
||||
69 69 | open(file="foo", buffering=- 1, encoding=None, errors=None, mode='Ub', newline=None, closefd=True, opener=None)
|
||||
|
|
|
@ -11,7 +11,7 @@ UP024_0.py:6:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `EnvironmentError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
3 3 | # These should be fixed
|
||||
4 4 | try:
|
||||
5 5 | pass
|
||||
|
@ -31,7 +31,7 @@ UP024_0.py:11:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `IOError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
8 8 |
|
||||
9 9 | try:
|
||||
10 10 | pass
|
||||
|
@ -51,7 +51,7 @@ UP024_0.py:16:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `WindowsError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
13 13 |
|
||||
14 14 | try:
|
||||
15 15 | pass
|
||||
|
@ -71,7 +71,7 @@ UP024_0.py:21:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `mmap.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
18 18 |
|
||||
19 19 | try:
|
||||
20 20 | pass
|
||||
|
@ -91,7 +91,7 @@ UP024_0.py:26:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `select.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
23 23 |
|
||||
24 24 | try:
|
||||
25 25 | pass
|
||||
|
@ -111,7 +111,7 @@ UP024_0.py:31:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `socket.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
28 28 |
|
||||
29 29 | try:
|
||||
30 30 | pass
|
||||
|
@ -131,7 +131,7 @@ UP024_0.py:36:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
33 33 |
|
||||
34 34 | try:
|
||||
35 35 | pass
|
||||
|
@ -152,7 +152,7 @@ UP024_0.py:43:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
40 40 |
|
||||
41 41 | try:
|
||||
42 42 | pass
|
||||
|
@ -173,7 +173,7 @@ UP024_0.py:47:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
44 44 | pass
|
||||
45 45 | try:
|
||||
46 46 | pass
|
||||
|
@ -193,7 +193,7 @@ UP024_0.py:51:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
48 48 | pass
|
||||
49 49 | try:
|
||||
50 50 | pass
|
||||
|
@ -213,7 +213,7 @@ UP024_0.py:58:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
55 55 |
|
||||
56 56 | try:
|
||||
57 57 | pass
|
||||
|
@ -234,7 +234,7 @@ UP024_0.py:65:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
62 62 | from .mmap import error
|
||||
63 63 | try:
|
||||
64 64 | pass
|
||||
|
@ -254,7 +254,7 @@ UP024_0.py:87:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `mmap.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
84 84 | pass
|
||||
85 85 | try:
|
||||
86 86 | pass
|
||||
|
|
|
@ -12,7 +12,7 @@ UP024_1.py:5:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
2 2 |
|
||||
3 3 | try:
|
||||
4 4 | pass
|
||||
|
@ -32,7 +32,7 @@ UP024_1.py:7:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
4 4 | pass
|
||||
5 5 | except (OSError, mmap.error, IOError):
|
||||
6 6 | pass
|
||||
|
@ -57,7 +57,7 @@ UP024_1.py:12:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
9 9 |
|
||||
10 10 | try:
|
||||
11 11 | pass
|
||||
|
|
|
@ -12,7 +12,7 @@ UP024_2.py:10:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `socket.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
7 7 |
|
||||
8 8 | # Testing the modules
|
||||
9 9 | import socket, mmap, select
|
||||
|
@ -32,7 +32,7 @@ UP024_2.py:11:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `mmap.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
8 8 | # Testing the modules
|
||||
9 9 | import socket, mmap, select
|
||||
10 10 | raise socket.error
|
||||
|
@ -53,7 +53,7 @@ UP024_2.py:12:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `select.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
9 9 | import socket, mmap, select
|
||||
10 10 | raise socket.error
|
||||
11 11 | raise mmap.error
|
||||
|
@ -74,7 +74,7 @@ UP024_2.py:14:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `socket.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
11 11 | raise mmap.error
|
||||
12 12 | raise select.error
|
||||
13 13 |
|
||||
|
@ -93,7 +93,7 @@ UP024_2.py:15:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `mmap.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
12 12 | raise select.error
|
||||
13 13 |
|
||||
14 14 | raise socket.error()
|
||||
|
@ -114,7 +114,7 @@ UP024_2.py:16:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `select.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
13 13 |
|
||||
14 14 | raise socket.error()
|
||||
15 15 | raise mmap.error(1)
|
||||
|
@ -135,7 +135,7 @@ UP024_2.py:18:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `socket.error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
15 15 | raise mmap.error(1)
|
||||
16 16 | raise select.error(1, 2)
|
||||
17 17 |
|
||||
|
@ -155,7 +155,7 @@ UP024_2.py:25:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
22 22 | )
|
||||
23 23 |
|
||||
24 24 | from mmap import error
|
||||
|
@ -175,7 +175,7 @@ UP024_2.py:28:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
25 25 | raise error
|
||||
26 26 |
|
||||
27 27 | from socket import error
|
||||
|
@ -195,7 +195,7 @@ UP024_2.py:31:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `error` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
28 28 | raise error(1)
|
||||
29 29 |
|
||||
30 30 | from select import error
|
||||
|
@ -215,7 +215,7 @@ UP024_2.py:34:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `EnvironmentError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
31 31 | raise error(1, 2)
|
||||
32 32 |
|
||||
33 33 | # Testing the names
|
||||
|
@ -235,7 +235,7 @@ UP024_2.py:35:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `IOError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
32 32 |
|
||||
33 33 | # Testing the names
|
||||
34 34 | raise EnvironmentError
|
||||
|
@ -256,7 +256,7 @@ UP024_2.py:36:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `WindowsError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
33 33 | # Testing the names
|
||||
34 34 | raise EnvironmentError
|
||||
35 35 | raise IOError
|
||||
|
@ -277,7 +277,7 @@ UP024_2.py:38:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `EnvironmentError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
35 35 | raise IOError
|
||||
36 36 | raise WindowsError
|
||||
37 37 |
|
||||
|
@ -296,7 +296,7 @@ UP024_2.py:39:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `IOError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
36 36 | raise WindowsError
|
||||
37 37 |
|
||||
38 38 | raise EnvironmentError()
|
||||
|
@ -317,7 +317,7 @@ UP024_2.py:40:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `WindowsError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
37 37 |
|
||||
38 38 | raise EnvironmentError()
|
||||
39 39 | raise IOError(1)
|
||||
|
@ -338,7 +338,7 @@ UP024_2.py:42:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `EnvironmentError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
39 39 | raise IOError(1)
|
||||
40 40 | raise WindowsError(1, 2)
|
||||
41 41 |
|
||||
|
@ -359,7 +359,7 @@ UP024_2.py:48:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `WindowsError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
45 45 | 3,
|
||||
46 46 | )
|
||||
47 47 |
|
||||
|
@ -377,7 +377,7 @@ UP024_2.py:49:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `EnvironmentError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
46 46 | )
|
||||
47 47 |
|
||||
48 48 | raise WindowsError
|
||||
|
@ -394,7 +394,7 @@ UP024_2.py:50:7: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace `IOError` with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
47 47 |
|
||||
48 48 | raise WindowsError
|
||||
49 49 | raise EnvironmentError(1)
|
||||
|
|
|
@ -11,7 +11,7 @@ UP024_4.py:9:8: UP024 [*] Replace aliased errors with `OSError`
|
|||
|
|
||||
= help: Replace with builtin `OSError`
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
6 6 | conn = Connection(settings.CELERY_BROKER_URL)
|
||||
7 7 | conn.ensure_connection(max_retries=2)
|
||||
8 8 | conn._close()
|
||||
|
|
|
@ -9,7 +9,7 @@ UP037.py:18:14: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg
|
||||
16 16 |
|
||||
17 17 |
|
||||
|
@ -27,7 +27,7 @@ UP037.py:18:28: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
15 15 | from mypy_extensions import Arg, DefaultArg, DefaultNamedArg, NamedArg, VarArg
|
||||
16 16 |
|
||||
17 17 |
|
||||
|
@ -45,7 +45,7 @@ UP037.py:19:8: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
16 16 |
|
||||
17 17 |
|
||||
18 18 | def foo(var: "MyClass") -> "MyClass":
|
||||
|
@ -63,7 +63,7 @@ UP037.py:22:21: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
19 19 | x: "MyClass"
|
||||
20 20 |
|
||||
21 21 |
|
||||
|
@ -81,7 +81,7 @@ UP037.py:26:16: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
23 23 | pass
|
||||
24 24 |
|
||||
25 25 |
|
||||
|
@ -99,7 +99,7 @@ UP037.py:26:33: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
23 23 | pass
|
||||
24 24 |
|
||||
25 25 |
|
||||
|
@ -118,7 +118,7 @@ UP037.py:30:10: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
27 27 | pass
|
||||
28 28 |
|
||||
29 29 |
|
||||
|
@ -137,7 +137,7 @@ UP037.py:32:14: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
29 29 |
|
||||
30 30 | x: Tuple["MyClass"]
|
||||
31 31 |
|
||||
|
@ -155,7 +155,7 @@ UP037.py:36:8: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
33 33 |
|
||||
34 34 |
|
||||
35 35 | class Foo(NamedTuple):
|
||||
|
@ -173,7 +173,7 @@ UP037.py:40:27: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
37 37 |
|
||||
38 38 |
|
||||
39 39 | class D(TypedDict):
|
||||
|
@ -191,7 +191,7 @@ UP037.py:44:31: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
41 41 |
|
||||
42 42 |
|
||||
43 43 | class D(TypedDict):
|
||||
|
@ -210,7 +210,7 @@ UP037.py:47:14: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
44 44 | E: TypedDict("E", {"foo": "int"})
|
||||
45 45 |
|
||||
46 46 |
|
||||
|
@ -231,7 +231,7 @@ UP037.py:49:8: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
46 46 |
|
||||
47 47 | x: Annotated["str", "metadata"]
|
||||
48 48 |
|
||||
|
@ -252,7 +252,7 @@ UP037.py:51:15: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
48 48 |
|
||||
49 49 | x: Arg("str", "name")
|
||||
50 50 |
|
||||
|
@ -273,7 +273,7 @@ UP037.py:53:13: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
50 50 |
|
||||
51 51 | x: DefaultArg("str", "name")
|
||||
52 52 |
|
||||
|
@ -294,7 +294,7 @@ UP037.py:55:20: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
52 52 |
|
||||
53 53 | x: NamedArg("str", "name")
|
||||
54 54 |
|
||||
|
@ -315,7 +315,7 @@ UP037.py:57:20: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
54 54 |
|
||||
55 55 | x: DefaultNamedArg("str", "name")
|
||||
56 56 |
|
||||
|
@ -336,7 +336,7 @@ UP037.py:59:11: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
56 56 |
|
||||
57 57 | x: DefaultNamedArg("str", name="name")
|
||||
58 58 |
|
||||
|
@ -357,7 +357,7 @@ UP037.py:61:19: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
58 58 |
|
||||
59 59 | x: VarArg("str")
|
||||
60 60 |
|
||||
|
@ -378,7 +378,7 @@ UP037.py:63:29: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
60 60 |
|
||||
61 61 | x: List[List[List["MyClass"]]]
|
||||
62 62 |
|
||||
|
@ -399,7 +399,7 @@ UP037.py:63:45: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
60 60 |
|
||||
61 61 | x: List[List[List["MyClass"]]]
|
||||
62 62 |
|
||||
|
@ -420,7 +420,7 @@ UP037.py:65:29: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
62 62 |
|
||||
63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")])
|
||||
64 64 |
|
||||
|
@ -441,7 +441,7 @@ UP037.py:65:36: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
62 62 |
|
||||
63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")])
|
||||
64 64 |
|
||||
|
@ -462,7 +462,7 @@ UP037.py:65:45: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
62 62 |
|
||||
63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")])
|
||||
64 64 |
|
||||
|
@ -483,7 +483,7 @@ UP037.py:65:52: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
62 62 |
|
||||
63 63 | x: NamedTuple("X", [("foo", "int"), ("bar", "str")])
|
||||
64 64 |
|
||||
|
@ -504,7 +504,7 @@ UP037.py:67:24: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
64 64 |
|
||||
65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")])
|
||||
66 66 |
|
||||
|
@ -525,7 +525,7 @@ UP037.py:67:38: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
64 64 |
|
||||
65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")])
|
||||
66 66 |
|
||||
|
@ -546,7 +546,7 @@ UP037.py:67:45: UP037 [*] Remove quotes from type annotation
|
|||
|
|
||||
= help: Remove quotes
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Fix
|
||||
64 64 |
|
||||
65 65 | x: NamedTuple("X", fields=[("foo", "int"), ("bar", "str")])
|
||||
66 66 |
|
||||
|
|
|
@ -256,8 +256,7 @@ impl Candidate {
|
|||
);
|
||||
if settings.rules.enabled(diagnostic.kind.rule()) {
|
||||
if settings.rules.should_fix(diagnostic.kind.rule()) {
|
||||
#[allow(deprecated)]
|
||||
diagnostic.set_fix(Fix::unspecified(Edit::range_replacement(
|
||||
diagnostic.set_fix(Fix::manual(Edit::range_replacement(
|
||||
self.representant.to_string(),
|
||||
char_range,
|
||||
)));
|
||||
|
|
|
@ -9,7 +9,7 @@ confusables.py:1:6: RUF001 [*] String contains ambiguous `𝐁` (MATHEMATICAL BO
|
|||
|
|
||||
= help: Replace `𝐁` (MATHEMATICAL BOLD CAPITAL B) with `B` (LATIN CAPITAL LETTER B)
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
1 |-x = "𝐁ad string"
|
||||
1 |+x = "Bad string"
|
||||
2 2 | y = "−"
|
||||
|
@ -26,7 +26,7 @@ confusables.py:6:56: RUF002 [*] Docstring contains ambiguous `)` (FULLWIDTH RI
|
|||
|
|
||||
= help: Replace `)` (FULLWIDTH RIGHT PARENTHESIS) with `)` (RIGHT PARENTHESIS)
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
3 3 |
|
||||
4 4 |
|
||||
5 5 | def f():
|
||||
|
@ -46,7 +46,7 @@ confusables.py:7:62: RUF003 [*] Comment contains ambiguous `᜵` (PHILIPPINE SIN
|
|||
|
|
||||
= help: Replace `᜵` (PHILIPPINE SINGLE PUNCTUATION) with `/` (SOLIDUS)
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
4 4 |
|
||||
5 5 | def f():
|
||||
6 6 | """Here's a docstring with an unusual parenthesis: )"""
|
||||
|
@ -64,7 +64,7 @@ confusables.py:17:6: RUF001 [*] String contains ambiguous `𝐁` (MATHEMATICAL B
|
|||
|
|
||||
= help: Replace `𝐁` (MATHEMATICAL BOLD CAPITAL B) with `B` (LATIN CAPITAL LETTER B)
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
14 14 | ...
|
||||
15 15 |
|
||||
16 16 |
|
||||
|
@ -85,7 +85,7 @@ confusables.py:26:10: RUF001 [*] String contains ambiguous `α` (GREEK SMALL LET
|
|||
|
|
||||
= help: Replace `α` (GREEK SMALL LETTER ALPHA) with `a` (LATIN SMALL LETTER A)
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
23 23 |
|
||||
24 24 | # The first word should be ignored, while the second should be included, since it
|
||||
25 25 | # contains ASCII.
|
||||
|
@ -104,7 +104,7 @@ confusables.py:31:6: RUF001 [*] String contains ambiguous `Р` (CYRILLIC CAPITAL
|
|||
|
|
||||
= help: Replace `Р` (CYRILLIC CAPITAL LETTER ER) with `P` (LATIN CAPITAL LETTER P)
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
28 28 | # The two characters should be flagged here. The first character is a "word"
|
||||
29 29 | # consisting of a single ambiguous character, while the second character is a "word
|
||||
30 30 | # boundary" (whitespace) that it itself ambiguous.
|
||||
|
@ -120,7 +120,7 @@ confusables.py:31:7: RUF001 [*] String contains ambiguous ` ` (EN QUAD). Did y
|
|||
|
|
||||
= help: Replace ` ` (EN QUAD) with ` ` (SPACE)
|
||||
|
||||
ℹ Suggested fix
|
||||
ℹ Possible fix
|
||||
28 28 | # The two characters should be flagged here. The first character is a "word"
|
||||
29 29 | # consisting of a single ambiguous character, while the second character is a "word
|
||||
30 30 | # boundary" (whitespace) that it itself ambiguous.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue