-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ruff] Do not remove parens for tuples with starred expressions in Py…
…thon <=3.10 `RUF031` (#12784)
- Loading branch information
Showing
6 changed files
with
226 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
.../snapshots/ruff_linter__rules__ruff__tests__no_remove_parentheses_starred_expr_py310.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/ruff/mod.rs | ||
--- | ||
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)] | ||
| ^^^^^ RUF031 | ||
3 | d[( | ||
4 | 1, | ||
| | ||
= help: Remove the parentheses. | ||
|
||
ℹ Safe fix | ||
1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} | ||
2 |-d[(1,2)] | ||
2 |+d[1,2] | ||
3 3 | d[( | ||
4 4 | 1, | ||
5 5 | 2 | ||
|
||
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)] | ||
3 | d[( | ||
| ___^ | ||
4 | | 1, | ||
5 | | 2 | ||
6 | | )] | ||
| |_^ RUF031 | ||
7 | d[ | ||
8 | 1, | ||
| | ||
= help: Remove the parentheses. | ||
|
||
ℹ Safe fix | ||
1 1 | d = {(1,2):"a",(3,4):"b",(5,6,7):"c",(8,):"d"} | ||
2 2 | d[(1,2)] | ||
3 |-d[( | ||
3 |+d[ | ||
4 4 | 1, | ||
5 5 | 2 | ||
6 |-)] | ||
6 |+] | ||
7 7 | d[ | ||
8 8 | 1, | ||
9 9 | 2 | ||
|
||
RUF031.py:11:3: RUF031 [*] Avoid parentheses for tuples in subscripts. | ||
| | ||
9 | 2 | ||
10 | ] | ||
11 | d[(2,4)] | ||
| ^^^^^ RUF031 | ||
12 | d[(5,6,7)] | ||
13 | d[(8,)] | ||
| | ||
= help: Remove the parentheses. | ||
|
||
ℹ Safe fix | ||
8 8 | 1, | ||
9 9 | 2 | ||
10 10 | ] | ||
11 |-d[(2,4)] | ||
11 |+d[2,4] | ||
12 12 | d[(5,6,7)] | ||
13 13 | d[(8,)] | ||
14 14 | d[tuple(1,2)] | ||
|
||
RUF031.py:12:3: RUF031 [*] Avoid parentheses for tuples in subscripts. | ||
| | ||
10 | ] | ||
11 | d[(2,4)] | ||
12 | d[(5,6,7)] | ||
| ^^^^^^^ RUF031 | ||
13 | d[(8,)] | ||
14 | d[tuple(1,2)] | ||
| | ||
= help: Remove the parentheses. | ||
|
||
ℹ Safe fix | ||
9 9 | 2 | ||
10 10 | ] | ||
11 11 | d[(2,4)] | ||
12 |-d[(5,6,7)] | ||
12 |+d[5,6,7] | ||
13 13 | d[(8,)] | ||
14 14 | d[tuple(1,2)] | ||
15 15 | d[tuple(8)] | ||
|
||
RUF031.py:13:3: RUF031 [*] Avoid parentheses for tuples in subscripts. | ||
| | ||
11 | d[(2,4)] | ||
12 | d[(5,6,7)] | ||
13 | d[(8,)] | ||
| ^^^^ RUF031 | ||
14 | d[tuple(1,2)] | ||
15 | d[tuple(8)] | ||
| | ||
= help: Remove the parentheses. | ||
|
||
ℹ Safe fix | ||
10 10 | ] | ||
11 11 | d[(2,4)] | ||
12 12 | d[(5,6,7)] | ||
13 |-d[(8,)] | ||
13 |+d[8,] | ||
14 14 | d[tuple(1,2)] | ||
15 15 | d[tuple(8)] | ||
16 16 | d[1,2] | ||
|
||
RUF031.py:20:3: RUF031 [*] Avoid parentheses for tuples in subscripts. | ||
| | ||
18 | d[5,6,7] | ||
19 | e = {((1,2),(3,4)):"a"} | ||
20 | e[((1,2),(3,4))] | ||
| ^^^^^^^^^^^^^ RUF031 | ||
21 | e[(1,2),(3,4)] | ||
| | ||
= help: Remove the parentheses. | ||
|
||
ℹ Safe fix | ||
17 17 | d[3,4] | ||
18 18 | d[5,6,7] | ||
19 19 | e = {((1,2),(3,4)):"a"} | ||
20 |-e[((1,2),(3,4))] | ||
21 20 | e[(1,2),(3,4)] | ||
21 |+e[(1,2),(3,4)] | ||
22 22 | | ||
23 23 | token_features[ | ||
24 24 | (window_position, feature_name) | ||
|
||
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. | ||
|
||
ℹ Safe fix | ||
21 21 | e[(1,2),(3,4)] | ||
22 22 | | ||
23 23 | token_features[ | ||
24 |- (window_position, feature_name) | ||
24 |+ window_position, feature_name | ||
25 25 | ] = self._extract_raw_features_from_token | ||
26 26 | | ||
27 27 | d[1,] | ||
|
||
RUF031.py:28:3: RUF031 [*] Avoid parentheses for tuples in subscripts. | ||
| | ||
27 | d[1,] | ||
28 | d[(1,)] | ||
| ^^^^ RUF031 | ||
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. | ||
|
||
ℹ Safe fix | ||
25 25 | ] = self._extract_raw_features_from_token | ||
26 26 | | ||
27 27 | d[1,] | ||
28 |-d[(1,)] | ||
28 |+d[1,] | ||
29 29 | d[()] # empty tuples should be ignored | ||
30 30 | d[:,] # slices in the subscript lead to syntax error if parens are added | ||
31 31 | d[1,2,:] |