mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Improve some rule messages and docs (#14068)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz (push) Blocked by required conditions
CI / Fuzz the parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz (push) Blocked by required conditions
CI / Fuzz the parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
This commit is contained in:
parent
f09dc8b67c
commit
2b0cdd2338
8 changed files with 70 additions and 70 deletions
|
@ -42,7 +42,7 @@ impl AlwaysFixableViolation for DecimalFromFloatLiteral {
|
|||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
"Use a string literal instead".to_string()
|
||||
"Replace with string literal".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,17 +46,17 @@ impl AlwaysFixableViolation for IncorrectlyParenthesizedTupleInSubscript {
|
|||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
if self.prefer_parentheses {
|
||||
format!("Use parentheses for tuples in subscripts.")
|
||||
format!("Use parentheses for tuples in subscripts")
|
||||
} else {
|
||||
format!("Avoid parentheses for tuples in subscripts.")
|
||||
format!("Avoid parentheses for tuples in subscripts")
|
||||
}
|
||||
}
|
||||
|
||||
fn fix_title(&self) -> String {
|
||||
if self.prefer_parentheses {
|
||||
"Parenthesize the tuple.".to_string()
|
||||
"Parenthesize tuple".to_string()
|
||||
} else {
|
||||
"Remove the parentheses.".to_string()
|
||||
"Remove parentheses".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@ use ruff_python_ast as ast;
|
|||
use ruff_python_ast::comparable::ComparableExpr;
|
||||
|
||||
/// ## What it does
|
||||
/// Checks for useless if-else conditions with identical arms.
|
||||
/// Checks for useless `if`-`else` conditions with identical arms.
|
||||
///
|
||||
/// ## Why is this bad?
|
||||
/// Useless if-else conditions add unnecessary complexity to the code without
|
||||
/// Useless `if`-`else` conditions add unnecessary complexity to the code without
|
||||
/// providing any logical benefit.
|
||||
///
|
||||
/// Assigning the value directly is clearer and more explicit, and
|
||||
|
@ -31,11 +31,11 @@ pub struct UselessIfElse;
|
|||
impl Violation for UselessIfElse {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
format!("Useless if-else condition")
|
||||
format!("Useless `if`-`else` condition")
|
||||
}
|
||||
}
|
||||
|
||||
/// RUF031
|
||||
/// RUF034
|
||||
pub(crate) fn useless_if_else(checker: &mut Checker, if_expr: &ast::ExprIf) {
|
||||
let ast::ExprIf {
|
||||
body,
|
||||
|
@ -44,7 +44,7 @@ pub(crate) fn useless_if_else(checker: &mut Checker, if_expr: &ast::ExprIf) {
|
|||
..
|
||||
} = if_expr;
|
||||
|
||||
// Skip if the body and orelse are not the same
|
||||
// Skip if the `body` and `orelse` are not the same.
|
||||
if ComparableExpr::from(body) != ComparableExpr::from(orelse) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/ruff/mod.rs
|
||||
---
|
||||
RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"}
|
||||
2 | d[(1,2)]
|
||||
|
@ -9,7 +9,7 @@ RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
3 | d[(
|
||||
4 | 1,
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"}
|
||||
|
@ -19,7 +19,7 @@ RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
4 4 | 1,
|
||||
5 5 | 2
|
||||
|
||||
RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"}
|
||||
2 | d[(1,2)]
|
||||
|
@ -32,7 +32,7 @@ RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
7 | d[
|
||||
8 | 1,
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"}
|
||||
|
@ -47,7 +47,7 @@ RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
8 8 | 1,
|
||||
9 9 | 2
|
||||
|
||||
RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
9 | 2
|
||||
10 | ]
|
||||
|
@ -56,7 +56,7 @@ RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
12 | d[(5,6,7)]
|
||||
13 | d[(8,)]
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
8 8 | 1,
|
||||
|
@ -68,7 +68,7 @@ RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
13 13 | d[(8,)]
|
||||
14 14 | d[tuple(1,2)]
|
||||
|
||||
RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
10 | ]
|
||||
11 | d[(2,4)]
|
||||
|
@ -77,7 +77,7 @@ RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
13 | d[(8,)]
|
||||
14 | d[tuple(1,2)]
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
9 9 | 2
|
||||
|
@ -89,7 +89,7 @@ RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
14 14 | d[tuple(1,2)]
|
||||
15 15 | d[tuple(8)]
|
||||
|
||||
RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
11 | d[(2,4)]
|
||||
12 | d[(5,6,7)]
|
||||
|
@ -98,7 +98,7 @@ RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
14 | d[tuple(1,2)]
|
||||
15 | d[tuple(8)]
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
10 10 | ]
|
||||
|
@ -110,7 +110,7 @@ RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
15 15 | d[tuple(8)]
|
||||
16 16 | d[1,2]
|
||||
|
||||
RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
18 | d[5,6,7]
|
||||
19 | e = {((1,2),(3,4)):"a"}
|
||||
|
@ -118,7 +118,7 @@ RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
| ^^^^^^^^^^^^^ RUF031
|
||||
21 | e[(1,2),(3,4)]
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
17 17 | d[3,4]
|
||||
|
@ -131,14 +131,14 @@ RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
23 23 | token_features[
|
||||
24 24 | (window_position, feature_name)
|
||||
|
||||
RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
23 | token_features[
|
||||
24 | (window_position, feature_name)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF031
|
||||
25 | ] = self._extract_raw_features_from_token
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
21 21 | e[(1,2),(3,4)]
|
||||
|
@ -150,7 +150,7 @@ RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
26 26 |
|
||||
27 27 | d[1,]
|
||||
|
||||
RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
27 | d[1,]
|
||||
28 | d[(1,)]
|
||||
|
@ -158,7 +158,7 @@ RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
29 | d[()] # empty tuples should be ignored
|
||||
30 | d[:,] # slices in the subscript lead to syntax error if parens are added
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
25 25 | ] = self._extract_raw_features_from_token
|
||||
|
@ -170,7 +170,7 @@ RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
30 30 | d[:,] # slices in the subscript lead to syntax error if parens are added
|
||||
31 31 | d[1,2,:]
|
||||
|
||||
RUF031.py:36:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:36:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
34 | # Python <=3.10 to avoid syntax error.
|
||||
35 | # https://github.com/astral-sh/ruff/issues/12776
|
||||
|
@ -179,7 +179,7 @@ RUF031.py:36:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
37 |
|
||||
38 | x: dict[str, int] # tuples inside type annotations should never be altered
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
33 33 | # Should keep these parentheses in
|
||||
|
|
|
@ -10,7 +10,7 @@ RUF032.py:6:17: RUF032 [*] `Decimal()` called with float literal argument
|
|||
7 |
|
||||
8 | decimal.Decimal("0.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
3 3 | # Tests with fully qualified import
|
||||
|
@ -31,7 +31,7 @@ RUF032.py:12:17: RUF032 [*] `Decimal()` called with float literal argument
|
|||
13 |
|
||||
14 | decimal.Decimal("10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
9 9 |
|
||||
|
@ -52,7 +52,7 @@ RUF032.py:18:17: RUF032 [*] `Decimal()` called with float literal argument
|
|||
19 |
|
||||
20 | decimal.Decimal("-10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
15 15 |
|
||||
|
@ -73,7 +73,7 @@ RUF032.py:33:15: RUF032 [*] `Decimal()` called with float literal argument
|
|||
34 |
|
||||
35 | val = Decimal("0.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
30 30 |
|
||||
|
@ -94,7 +94,7 @@ RUF032.py:39:15: RUF032 [*] `Decimal()` called with float literal argument
|
|||
40 |
|
||||
41 | val = Decimal("10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
36 36 |
|
||||
|
@ -115,7 +115,7 @@ RUF032.py:45:15: RUF032 [*] `Decimal()` called with float literal argument
|
|||
46 |
|
||||
47 | val = Decimal("-10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
42 42 |
|
||||
|
@ -136,7 +136,7 @@ RUF032.py:56:15: RUF032 [*] `Decimal()` called with float literal argument
|
|||
57 |
|
||||
58 | val = Decimal(-+--++--4.0) # Suggest `Decimal("-4.0")`
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
53 53 | # See https://github.com/astral-sh/ruff/issues/13258
|
||||
|
@ -155,7 +155,7 @@ RUF032.py:58:15: RUF032 [*] `Decimal()` called with float literal argument
|
|||
58 | val = Decimal(-+--++--4.0) # Suggest `Decimal("-4.0")`
|
||||
| ^^^^^^^^^^^ RUF032
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
55 55 |
|
||||
|
@ -176,7 +176,7 @@ RUF032.py:88:23: RUF032 [*] `Decimal()` called with float literal argument
|
|||
89 |
|
||||
90 | val = decimal.Decimal("0.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
85 85 |
|
||||
|
@ -197,7 +197,7 @@ RUF032.py:92:23: RUF032 [*] `Decimal()` called with float literal argument
|
|||
93 |
|
||||
94 | val = decimal.Decimal("10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
89 89 |
|
||||
|
@ -218,7 +218,7 @@ RUF032.py:96:23: RUF032 [*] `Decimal()` called with float literal argument
|
|||
97 |
|
||||
98 | val = decimal.Decimal("-10.0")
|
||||
|
|
||||
= help: Use a string literal instead
|
||||
= help: Replace with string literal
|
||||
|
||||
ℹ Unsafe fix
|
||||
93 93 |
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/ruff/mod.rs
|
||||
---
|
||||
RUF034.py:5:5: RUF034 Useless if-else condition
|
||||
RUF034.py:5:5: RUF034 Useless `if`-`else` condition
|
||||
|
|
||||
4 | # Invalid
|
||||
5 | x = 1 if True else 1
|
||||
|
@ -10,7 +10,7 @@ RUF034.py:5:5: RUF034 Useless if-else condition
|
|||
7 | # Invalid
|
||||
|
|
||||
|
||||
RUF034.py:8:5: RUF034 Useless if-else condition
|
||||
RUF034.py:8:5: RUF034 Useless `if`-`else` condition
|
||||
|
|
||||
7 | # Invalid
|
||||
8 | x = "a" if True else "a"
|
||||
|
@ -19,7 +19,7 @@ RUF034.py:8:5: RUF034 Useless if-else condition
|
|||
10 | # Invalid
|
||||
|
|
||||
|
||||
RUF034.py:11:5: RUF034 Useless if-else condition
|
||||
RUF034.py:11:5: RUF034 Useless `if`-`else` condition
|
||||
|
|
||||
10 | # Invalid
|
||||
11 | x = 0.1 if False else 0.1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/ruff/mod.rs
|
||||
---
|
||||
RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"}
|
||||
2 | d[(1,2)]
|
||||
|
@ -9,7 +9,7 @@ RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
3 | d[(
|
||||
4 | 1,
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"}
|
||||
|
@ -19,7 +19,7 @@ RUF031.py:2:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
4 4 | 1,
|
||||
5 5 | 2
|
||||
|
||||
RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"}
|
||||
2 | d[(1,2)]
|
||||
|
@ -32,7 +32,7 @@ RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
7 | d[
|
||||
8 | 1,
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"}
|
||||
|
@ -47,7 +47,7 @@ RUF031.py:3:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
8 8 | 1,
|
||||
9 9 | 2
|
||||
|
||||
RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
9 | 2
|
||||
10 | ]
|
||||
|
@ -56,7 +56,7 @@ RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
12 | d[(5,6,7)]
|
||||
13 | d[(8,)]
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
8 8 | 1,
|
||||
|
@ -68,7 +68,7 @@ RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
13 13 | d[(8,)]
|
||||
14 14 | d[tuple(1,2)]
|
||||
|
||||
RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
10 | ]
|
||||
11 | d[(2,4)]
|
||||
|
@ -77,7 +77,7 @@ RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
13 | d[(8,)]
|
||||
14 | d[tuple(1,2)]
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
9 9 | 2
|
||||
|
@ -89,7 +89,7 @@ RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
14 14 | d[tuple(1,2)]
|
||||
15 15 | d[tuple(8)]
|
||||
|
||||
RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
11 | d[(2,4)]
|
||||
12 | d[(5,6,7)]
|
||||
|
@ -98,7 +98,7 @@ RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
14 | d[tuple(1,2)]
|
||||
15 | d[tuple(8)]
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
10 10 | ]
|
||||
|
@ -110,7 +110,7 @@ RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
15 15 | d[tuple(8)]
|
||||
16 16 | d[1,2]
|
||||
|
||||
RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
18 | d[5,6,7]
|
||||
19 | e = {((1,2),(3,4)):"a"}
|
||||
|
@ -118,7 +118,7 @@ RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
| ^^^^^^^^^^^^^ RUF031
|
||||
21 | e[(1,2),(3,4)]
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
17 17 | d[3,4]
|
||||
|
@ -131,14 +131,14 @@ RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
23 23 | token_features[
|
||||
24 24 | (window_position, feature_name)
|
||||
|
||||
RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
23 | token_features[
|
||||
24 | (window_position, feature_name)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RUF031
|
||||
25 | ] = self._extract_raw_features_from_token
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
21 21 | e[(1,2),(3,4)]
|
||||
|
@ -150,7 +150,7 @@ RUF031.py:24:5: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
26 26 |
|
||||
27 27 | d[1,]
|
||||
|
||||
RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
||||
RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts
|
||||
|
|
||||
27 | d[1,]
|
||||
28 | d[(1,)]
|
||||
|
@ -158,7 +158,7 @@ RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts.
|
|||
29 | d[()] # empty tuples should be ignored
|
||||
30 | d[:,] # slices in the subscript lead to syntax error if parens are added
|
||||
|
|
||||
= help: Remove the parentheses.
|
||||
= help: Remove parentheses
|
||||
|
||||
ℹ Safe fix
|
||||
25 25 | ] = self._extract_raw_features_from_token
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
source: crates/ruff_linter/src/rules/ruff/mod.rs
|
||||
---
|
||||
RUF031_prefer_parens.py:8:5: RUF031 [*] Use parentheses for tuples in subscripts.
|
||||
RUF031_prefer_parens.py:8:5: RUF031 [*] Use parentheses for tuples in subscripts
|
||||
|
|
||||
6 | )]
|
||||
7 | d[
|
||||
|
@ -12,7 +12,7 @@ RUF031_prefer_parens.py:8:5: RUF031 [*] Use parentheses for tuples in subscripts
|
|||
10 | ]
|
||||
11 | d[(2,4)]
|
||||
|
|
||||
= help: Parenthesize the tuple.
|
||||
= help: Parenthesize tuple
|
||||
|
||||
ℹ Safe fix
|
||||
5 5 | 2
|
||||
|
@ -26,7 +26,7 @@ RUF031_prefer_parens.py:8:5: RUF031 [*] Use parentheses for tuples in subscripts
|
|||
11 11 | d[(2,4)]
|
||||
12 12 | d[(5,6,7)]
|
||||
|
||||
RUF031_prefer_parens.py:16:3: RUF031 [*] Use parentheses for tuples in subscripts.
|
||||
RUF031_prefer_parens.py:16:3: RUF031 [*] Use parentheses for tuples in subscripts
|
||||
|
|
||||
14 | d[tuple(1,2)]
|
||||
15 | d[tuple(8)]
|
||||
|
@ -35,7 +35,7 @@ RUF031_prefer_parens.py:16:3: RUF031 [*] Use parentheses for tuples in subscript
|
|||
17 | d[3,4]
|
||||
18 | d[5,6,7]
|
||||
|
|
||||
= help: Parenthesize the tuple.
|
||||
= help: Parenthesize tuple
|
||||
|
||||
ℹ Safe fix
|
||||
13 13 | d[(8,)]
|
||||
|
@ -47,7 +47,7 @@ RUF031_prefer_parens.py:16:3: RUF031 [*] Use parentheses for tuples in subscript
|
|||
18 18 | d[5,6,7]
|
||||
19 19 | e = {((1,2),(3,4)):"a"}
|
||||
|
||||
RUF031_prefer_parens.py:17:3: RUF031 [*] Use parentheses for tuples in subscripts.
|
||||
RUF031_prefer_parens.py:17:3: RUF031 [*] Use parentheses for tuples in subscripts
|
||||
|
|
||||
15 | d[tuple(8)]
|
||||
16 | d[1,2]
|
||||
|
@ -56,7 +56,7 @@ RUF031_prefer_parens.py:17:3: RUF031 [*] Use parentheses for tuples in subscript
|
|||
18 | d[5,6,7]
|
||||
19 | e = {((1,2),(3,4)):"a"}
|
||||
|
|
||||
= help: Parenthesize the tuple.
|
||||
= help: Parenthesize tuple
|
||||
|
||||
ℹ Safe fix
|
||||
14 14 | d[tuple(1,2)]
|
||||
|
@ -68,7 +68,7 @@ RUF031_prefer_parens.py:17:3: RUF031 [*] Use parentheses for tuples in subscript
|
|||
19 19 | e = {((1,2),(3,4)):"a"}
|
||||
20 20 | e[((1,2),(3,4))]
|
||||
|
||||
RUF031_prefer_parens.py:18:3: RUF031 [*] Use parentheses for tuples in subscripts.
|
||||
RUF031_prefer_parens.py:18:3: RUF031 [*] Use parentheses for tuples in subscripts
|
||||
|
|
||||
16 | d[1,2]
|
||||
17 | d[3,4]
|
||||
|
@ -77,7 +77,7 @@ RUF031_prefer_parens.py:18:3: RUF031 [*] Use parentheses for tuples in subscript
|
|||
19 | e = {((1,2),(3,4)):"a"}
|
||||
20 | e[((1,2),(3,4))]
|
||||
|
|
||||
= help: Parenthesize the tuple.
|
||||
= help: Parenthesize tuple
|
||||
|
||||
ℹ Safe fix
|
||||
15 15 | d[tuple(8)]
|
||||
|
@ -89,7 +89,7 @@ RUF031_prefer_parens.py:18:3: RUF031 [*] Use parentheses for tuples in subscript
|
|||
20 20 | e[((1,2),(3,4))]
|
||||
21 21 | e[(1,2),(3,4)]
|
||||
|
||||
RUF031_prefer_parens.py:21:3: RUF031 [*] Use parentheses for tuples in subscripts.
|
||||
RUF031_prefer_parens.py:21:3: RUF031 [*] Use parentheses for tuples in subscripts
|
||||
|
|
||||
19 | e = {((1,2),(3,4)):"a"}
|
||||
20 | e[((1,2),(3,4))]
|
||||
|
@ -98,7 +98,7 @@ RUF031_prefer_parens.py:21:3: RUF031 [*] Use parentheses for tuples in subscript
|
|||
22 |
|
||||
23 | token_features[
|
||||
|
|
||||
= help: Parenthesize the tuple.
|
||||
= help: Parenthesize tuple
|
||||
|
||||
ℹ Safe fix
|
||||
18 18 | d[5,6,7]
|
||||
|
@ -110,7 +110,7 @@ RUF031_prefer_parens.py:21:3: RUF031 [*] Use parentheses for tuples in subscript
|
|||
23 23 | token_features[
|
||||
24 24 | (window_position, feature_name)
|
||||
|
||||
RUF031_prefer_parens.py:26:3: RUF031 [*] Use parentheses for tuples in subscripts.
|
||||
RUF031_prefer_parens.py:26:3: RUF031 [*] Use parentheses for tuples in subscripts
|
||||
|
|
||||
24 | (window_position, feature_name)
|
||||
25 | ] = self._extract_raw_features_from_token
|
||||
|
@ -119,7 +119,7 @@ RUF031_prefer_parens.py:26:3: RUF031 [*] Use parentheses for tuples in subscript
|
|||
27 | d[(1,)]
|
||||
28 | d[()] # empty tuples should be ignored
|
||||
|
|
||||
= help: Parenthesize the tuple.
|
||||
= help: Parenthesize tuple
|
||||
|
||||
ℹ Safe fix
|
||||
23 23 | token_features[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue