-
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.
use
checker.semantic().resolve_call_path
- Loading branch information
1 parent
fc43d1b
commit bcae782
Showing
3 changed files
with
162 additions
and
94 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
235 changes: 148 additions & 87 deletions
235
...napshots/ruff_linter__rules__pylint__tests__PLR1736_unnecessary_list_index_lookup.py.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 |
---|---|---|
@@ -1,124 +1,185 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pylint/mod.rs | ||
--- | ||
unnecessary_list_index_lookup.py:5:6: PLR1736 [*] Unnecessary lookup of list item by index | ||
unnecessary_list_index_lookup.py:7:6: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
4 | def fix_these(): | ||
5 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
6 | def fix_these(): | ||
7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
6 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
7 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
| | ||
= help: Use existing item variable instead | ||
|
||
ℹ Safe fix | ||
2 2 | | ||
3 3 | | ||
4 4 | def fix_these(): | ||
5 |- [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
5 |+ [letter for index, letter in enumerate(letters)] # PLR1736 | ||
6 6 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
7 7 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
8 8 | | ||
|
||
unnecessary_list_index_lookup.py:6:6: PLR1736 [*] Unnecessary lookup of list item by index | ||
4 4 | | ||
5 5 | | ||
6 6 | def fix_these(): | ||
7 |- [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
7 |+ [letter for index, letter in enumerate(letters)] # PLR1736 | ||
8 8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
10 10 | | ||
|
||
unnecessary_list_index_lookup.py:8:6: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
4 | def fix_these(): | ||
5 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
6 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
6 | def fix_these(): | ||
7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
7 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
| | ||
= help: Use existing item variable instead | ||
|
||
ℹ Safe fix | ||
3 3 | | ||
4 4 | def fix_these(): | ||
5 5 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
6 |- {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
6 |+ {letter for index, letter in enumerate(letters)} # PLR1736 | ||
7 7 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
8 8 | | ||
9 9 | for index, letter in enumerate(letters): | ||
|
||
unnecessary_list_index_lookup.py:7:14: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
5 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
6 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
7 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
8 | | ||
9 | for index, letter in enumerate(letters): | ||
| | ||
= help: Use existing item variable instead | ||
5 5 | | ||
6 6 | def fix_these(): | ||
7 7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
8 |- {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
8 |+ {letter for index, letter in enumerate(letters)} # PLR1736 | ||
9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
10 10 | | ||
11 11 | for index, letter in enumerate(letters): | ||
|
||
unnecessary_list_index_lookup.py:9:14: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
10 | | ||
11 | for index, letter in enumerate(letters): | ||
| | ||
= help: Use existing item variable instead | ||
|
||
ℹ Safe fix | ||
6 6 | def fix_these(): | ||
7 7 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
8 8 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
9 |- {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
9 |+ {letter: letter for index, letter in enumerate(letters)} # PLR1736 | ||
10 10 | | ||
11 11 | for index, letter in enumerate(letters): | ||
12 12 | print(letters[index]) # PLR1736 | ||
|
||
unnecessary_list_index_lookup.py:12:15: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
11 | for index, letter in enumerate(letters): | ||
12 | print(letters[index]) # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
13 | blah = letters[index] # PLR1736 | ||
14 | assert letters[index] == "d" # PLR1736 | ||
| | ||
= help: Use existing item variable instead | ||
|
||
ℹ Safe fix | ||
9 9 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
10 10 | | ||
11 11 | for index, letter in enumerate(letters): | ||
12 |- print(letters[index]) # PLR1736 | ||
12 |+ print(letter) # PLR1736 | ||
13 13 | blah = letters[index] # PLR1736 | ||
14 14 | assert letters[index] == "d" # PLR1736 | ||
15 15 | | ||
|
||
unnecessary_list_index_lookup.py:13:16: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
11 | for index, letter in enumerate(letters): | ||
12 | print(letters[index]) # PLR1736 | ||
13 | blah = letters[index] # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
14 | assert letters[index] == "d" # PLR1736 | ||
| | ||
= help: Use existing item variable instead | ||
|
||
ℹ Safe fix | ||
10 10 | | ||
11 11 | for index, letter in enumerate(letters): | ||
12 12 | print(letters[index]) # PLR1736 | ||
13 |- blah = letters[index] # PLR1736 | ||
13 |+ blah = letter # PLR1736 | ||
14 14 | assert letters[index] == "d" # PLR1736 | ||
15 15 | | ||
16 16 | for index, letter in builtins.enumerate(letters): | ||
|
||
unnecessary_list_index_lookup.py:14:16: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
12 | print(letters[index]) # PLR1736 | ||
13 | blah = letters[index] # PLR1736 | ||
14 | assert letters[index] == "d" # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
15 | | ||
16 | for index, letter in builtins.enumerate(letters): | ||
| | ||
= help: Use existing item variable instead | ||
|
||
ℹ Safe fix | ||
4 4 | def fix_these(): | ||
5 5 | [letters[index] for index, letter in enumerate(letters)] # PLR1736 | ||
6 6 | {letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
7 |- {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
7 |+ {letter: letter for index, letter in enumerate(letters)} # PLR1736 | ||
8 8 | | ||
9 9 | for index, letter in enumerate(letters): | ||
10 10 | print(letters[index]) # PLR1736 | ||
|
||
unnecessary_list_index_lookup.py:10:15: PLR1736 [*] Unnecessary lookup of list item by index | ||
11 11 | for index, letter in enumerate(letters): | ||
12 12 | print(letters[index]) # PLR1736 | ||
13 13 | blah = letters[index] # PLR1736 | ||
14 |- assert letters[index] == "d" # PLR1736 | ||
14 |+ assert letter == "d" # PLR1736 | ||
15 15 | | ||
16 16 | for index, letter in builtins.enumerate(letters): | ||
17 17 | print(letters[index]) # PLR1736 | ||
|
||
unnecessary_list_index_lookup.py:17:15: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
9 | for index, letter in enumerate(letters): | ||
10 | print(letters[index]) # PLR1736 | ||
16 | for index, letter in builtins.enumerate(letters): | ||
17 | print(letters[index]) # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
11 | blah = letters[index] # PLR1736 | ||
12 | assert letters[index] == "d" # PLR1736 | ||
18 | blah = letters[index] # PLR1736 | ||
19 | assert letters[index] == "d" # PLR1736 | ||
| | ||
= help: Use existing item variable instead | ||
|
||
ℹ Safe fix | ||
7 7 | {letter: letters[index] for index, letter in enumerate(letters)} # PLR1736 | ||
8 8 | | ||
9 9 | for index, letter in enumerate(letters): | ||
10 |- print(letters[index]) # PLR1736 | ||
10 |+ print(letter) # PLR1736 | ||
11 11 | blah = letters[index] # PLR1736 | ||
12 12 | assert letters[index] == "d" # PLR1736 | ||
13 13 | | ||
|
||
unnecessary_list_index_lookup.py:11:16: PLR1736 [*] Unnecessary lookup of list item by index | ||
14 14 | assert letters[index] == "d" # PLR1736 | ||
15 15 | | ||
16 16 | for index, letter in builtins.enumerate(letters): | ||
17 |- print(letters[index]) # PLR1736 | ||
17 |+ print(letter) # PLR1736 | ||
18 18 | blah = letters[index] # PLR1736 | ||
19 19 | assert letters[index] == "d" # PLR1736 | ||
20 20 | | ||
|
||
unnecessary_list_index_lookup.py:18:16: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
9 | for index, letter in enumerate(letters): | ||
10 | print(letters[index]) # PLR1736 | ||
11 | blah = letters[index] # PLR1736 | ||
16 | for index, letter in builtins.enumerate(letters): | ||
17 | print(letters[index]) # PLR1736 | ||
18 | blah = letters[index] # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
12 | assert letters[index] == "d" # PLR1736 | ||
19 | assert letters[index] == "d" # PLR1736 | ||
| | ||
= help: Use existing item variable instead | ||
|
||
ℹ Safe fix | ||
8 8 | | ||
9 9 | for index, letter in enumerate(letters): | ||
10 10 | print(letters[index]) # PLR1736 | ||
11 |- blah = letters[index] # PLR1736 | ||
11 |+ blah = letter # PLR1736 | ||
12 12 | assert letters[index] == "d" # PLR1736 | ||
13 13 | | ||
14 14 | | ||
|
||
unnecessary_list_index_lookup.py:12:16: PLR1736 [*] Unnecessary lookup of list item by index | ||
15 15 | | ||
16 16 | for index, letter in builtins.enumerate(letters): | ||
17 17 | print(letters[index]) # PLR1736 | ||
18 |- blah = letters[index] # PLR1736 | ||
18 |+ blah = letter # PLR1736 | ||
19 19 | assert letters[index] == "d" # PLR1736 | ||
20 20 | | ||
21 21 | | ||
|
||
unnecessary_list_index_lookup.py:19:16: PLR1736 [*] Unnecessary lookup of list item by index | ||
| | ||
10 | print(letters[index]) # PLR1736 | ||
11 | blah = letters[index] # PLR1736 | ||
12 | assert letters[index] == "d" # PLR1736 | ||
17 | print(letters[index]) # PLR1736 | ||
18 | blah = letters[index] # PLR1736 | ||
19 | assert letters[index] == "d" # PLR1736 | ||
| ^^^^^^^^^^^^^^ PLR1736 | ||
| | ||
= help: Use existing item variable instead | ||
|
||
ℹ Safe fix | ||
9 9 | for index, letter in enumerate(letters): | ||
10 10 | print(letters[index]) # PLR1736 | ||
11 11 | blah = letters[index] # PLR1736 | ||
12 |- assert letters[index] == "d" # PLR1736 | ||
12 |+ assert letter == "d" # PLR1736 | ||
13 13 | | ||
14 14 | | ||
15 15 | def dont_fix_these(): | ||
16 16 | for index, letter in builtins.enumerate(letters): | ||
17 17 | print(letters[index]) # PLR1736 | ||
18 18 | blah = letters[index] # PLR1736 | ||
19 |- assert letters[index] == "d" # PLR1736 | ||
19 |+ assert letter == "d" # PLR1736 | ||
20 20 | | ||
21 21 | | ||
22 22 | def dont_fix_these(): | ||
|
||
|