---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
unnecessary_list_index_lookup.py:7:6: PLR1736 [*] Unnecessary lookup of list item by index
  |
6 | def fix_these():
7 |     [letters[index] for index, letter in enumerate(letters)]  # PLR1736
  |      ^^^^^^^^^^^^^^ 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 variable

ℹ Safe fix
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
  |
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
9 |     {letter: letters[index] for index, letter in enumerate(letters)}  # PLR1736
  |
  = help: Use existing variable

ℹ Safe fix
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 variable

ℹ 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 variable

ℹ 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 variable

ℹ 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 variable

ℹ Safe fix
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
   |
16 |     for index, letter in builtins.enumerate(letters):
17 |         print(letters[index])  # PLR1736
   |               ^^^^^^^^^^^^^^ PLR1736
18 |         blah = letters[index]  # PLR1736
19 |         assert letters[index]  == "d"  # PLR1736
   |
   = help: Use existing variable

ℹ Safe fix
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
   |
16 |     for index, letter in builtins.enumerate(letters):
17 |         print(letters[index])  # PLR1736
18 |         blah = letters[index]  # PLR1736
   |                ^^^^^^^^^^^^^^ PLR1736
19 |         assert letters[index]  == "d"  # PLR1736
   |
   = help: Use existing variable

ℹ Safe fix
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
   |
17 |         print(letters[index])  # PLR1736
18 |         blah = letters[index]  # PLR1736
19 |         assert letters[index]  == "d"  # PLR1736
   |                ^^^^^^^^^^^^^^ PLR1736
   |
   = help: Use existing variable

ℹ Safe fix
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():


