---
source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs
snapshot_kind: text
---
C419.py:1:5: C419 [*] Unnecessary list comprehension
  |
1 | any([x.id for x in bar])
  |     ^^^^^^^^^^^^^^^^^^^ C419
2 | all([x.id for x in bar])
3 | any(  # first comment
  |
  = help: Remove unnecessary comprehension

ℹ Unsafe fix
1   |-any([x.id for x in bar])
  1 |+any(x.id for x in bar)
2 2 | all([x.id for x in bar])
3 3 | any(  # first comment
4 4 |     [x.id for x in bar],  # second comment

C419.py:2:5: C419 [*] Unnecessary list comprehension
  |
1 | any([x.id for x in bar])
2 | all([x.id for x in bar])
  |     ^^^^^^^^^^^^^^^^^^^ C419
3 | any(  # first comment
4 |     [x.id for x in bar],  # second comment
  |
  = help: Remove unnecessary comprehension

ℹ Unsafe fix
1 1 | any([x.id for x in bar])
2   |-all([x.id for x in bar])
  2 |+all(x.id for x in bar)
3 3 | any(  # first comment
4 4 |     [x.id for x in bar],  # second comment
5 5 | )  # third comment

C419.py:4:5: C419 [*] Unnecessary list comprehension
  |
2 | all([x.id for x in bar])
3 | any(  # first comment
4 |     [x.id for x in bar],  # second comment
  |     ^^^^^^^^^^^^^^^^^^^ C419
5 | )  # third comment
6 | all(  # first comment
  |
  = help: Remove unnecessary comprehension

ℹ Unsafe fix
1 1 | any([x.id for x in bar])
2 2 | all([x.id for x in bar])
3 3 | any(  # first comment
4   |-    [x.id for x in bar],  # second comment
  4 |+    x.id for x in bar  # second comment
5 5 | )  # third comment
6 6 | all(  # first comment
7 7 |     [x.id for x in bar],  # second comment

C419.py:7:5: C419 [*] Unnecessary list comprehension
  |
5 | )  # third comment
6 | all(  # first comment
7 |     [x.id for x in bar],  # second comment
  |     ^^^^^^^^^^^^^^^^^^^ C419
8 | )  # third comment
9 | any({x.id for x in bar})
  |
  = help: Remove unnecessary comprehension

ℹ Unsafe fix
4 4 |     [x.id for x in bar],  # second comment
5 5 | )  # third comment
6 6 | all(  # first comment
7   |-    [x.id for x in bar],  # second comment
  7 |+    x.id for x in bar  # second comment
8 8 | )  # third comment
9 9 | any({x.id for x in bar})
10 10 | 

C419.py:9:5: C419 [*] Unnecessary set comprehension
   |
 7 |     [x.id for x in bar],  # second comment
 8 | )  # third comment
 9 | any({x.id for x in bar})
   |     ^^^^^^^^^^^^^^^^^^^ C419
10 | 
11 | # OK
   |
   = help: Remove unnecessary comprehension

ℹ Unsafe fix
6  6  | all(  # first comment
7  7  |     [x.id for x in bar],  # second comment
8  8  | )  # third comment
9     |-any({x.id for x in bar})
   9  |+any(x.id for x in bar)
10 10 | 
11 11 | # OK
12 12 | all(x.id for x in bar)

C419.py:28:5: C419 [*] Unnecessary list comprehension
   |
26 |   # Special comment handling
27 |   any(
28 |       [  # lbracket comment
   |  _____^
29 | |         # second line comment
30 | |         i.bit_count()
31 | |         # random middle comment
32 | |         for i in range(5)  # rbracket comment
33 | |     ]  # rpar comment
   | |_____^ C419
34 |       # trailing comment
35 |   )
   |
   = help: Remove unnecessary comprehension

ℹ Unsafe fix
25 25 | 
26 26 | # Special comment handling
27 27 | any(
28    |-    [  # lbracket comment
29    |-        # second line comment
30    |-        i.bit_count()
   28 |+    # lbracket comment
   29 |+    # second line comment
   30 |+    i.bit_count()
31 31 |         # random middle comment
32    |-        for i in range(5)  # rbracket comment
33    |-    ]  # rpar comment
   32 |+        for i in range(5)  # rbracket comment  # rpar comment
34 33 |     # trailing comment
35 34 | )
36 35 | 

C419.py:39:5: C419 [*] Unnecessary list comprehension
   |
37 |   # Weird case where the function call, opening bracket, and comment are all
38 |   # on the same line.
39 |   any([  # lbracket comment
   |  _____^
40 | |         # second line comment
41 | |         i.bit_count() for i in range(5)  # rbracket comment
42 | |     ]  # rpar comment
   | |_____^ C419
43 |   )
   |
   = help: Remove unnecessary comprehension

ℹ Unsafe fix
36 36 | 
37 37 | # Weird case where the function call, opening bracket, and comment are all
38 38 | # on the same line.
39    |-any([  # lbracket comment
40    |-        # second line comment
41    |-        i.bit_count() for i in range(5)  # rbracket comment
42    |-    ]  # rpar comment
   39 |+any(
   40 |+# lbracket comment
   41 |+# second line comment
   42 |+i.bit_count() for i in range(5)  # rbracket comment  # rpar comment
43 43 | )
44 44 | 
45 45 | ## Set comprehensions should only be linted

C419.py:49:5: C419 [*] Unnecessary set comprehension
   |
48 | # should be linted...
49 | any({x.id for x in bar})
   |     ^^^^^^^^^^^^^^^^^^^ C419
50 | all({x.id for x in bar})
   |
   = help: Remove unnecessary comprehension

ℹ Unsafe fix
46 46 | ## when function is invariant under duplication of inputs
47 47 | 
48 48 | # should be linted...
49    |-any({x.id for x in bar})
   49 |+any(x.id for x in bar)
50 50 | all({x.id for x in bar})
51 51 | 
52 52 | # should be linted in preview...

C419.py:50:5: C419 [*] Unnecessary set comprehension
   |
48 | # should be linted...
49 | any({x.id for x in bar})
50 | all({x.id for x in bar})
   |     ^^^^^^^^^^^^^^^^^^^ C419
51 | 
52 | # should be linted in preview...
   |
   = help: Remove unnecessary comprehension

ℹ Unsafe fix
47 47 | 
48 48 | # should be linted...
49 49 | any({x.id for x in bar})
50    |-all({x.id for x in bar})
   50 |+all(x.id for x in bar)
51 51 | 
52 52 | # should be linted in preview...
53 53 | min({x.id for x in bar})
