---
source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs
---
C419 [*] Unnecessary list comprehension
 --> C419_1.py:1:5
  |
1 | sum([x.val for x in bar])
  |     ^^^^^^^^^^^^^^^^^^^^
2 | min([x.val for x in bar])
3 | max([x.val for x in bar])
  |
help: Remove unnecessary comprehension
  |
  - sum([x.val for x in bar])
1 + sum(x.val for x in bar)
2 | min([x.val for x in bar])
  |
note: This is an unsafe fix and may change runtime behavior

C419 [*] Unnecessary list comprehension
 --> C419_1.py:2:5
  |
1 | sum([x.val for x in bar])
2 | min([x.val for x in bar])
  |     ^^^^^^^^^^^^^^^^^^^^
3 | max([x.val for x in bar])
4 | sum([x.val for x in bar], 0)
  |
help: Remove unnecessary comprehension
  |
1 | sum([x.val for x in bar])
  - min([x.val for x in bar])
2 + min(x.val for x in bar)
3 | max([x.val for x in bar])
  |
note: This is an unsafe fix and may change runtime behavior

C419 [*] Unnecessary list comprehension
 --> C419_1.py:3:5
  |
1 | sum([x.val for x in bar])
2 | min([x.val for x in bar])
3 | max([x.val for x in bar])
  |     ^^^^^^^^^^^^^^^^^^^^
4 | sum([x.val for x in bar], 0)
  |
help: Remove unnecessary comprehension
  |
2 | min([x.val for x in bar])
  - max([x.val for x in bar])
3 + max(x.val for x in bar)
4 | sum([x.val for x in bar], 0)
  |
note: This is an unsafe fix and may change runtime behavior

C419 [*] Unnecessary list comprehension
 --> C419_1.py:4:5
  |
2 | min([x.val for x in bar])
3 | max([x.val for x in bar])
4 | sum([x.val for x in bar], 0)
  |     ^^^^^^^^^^^^^^^^^^^^
5 |
6 | # OK
  |
help: Remove unnecessary comprehension
  |
3 | max([x.val for x in bar])
  - sum([x.val for x in bar], 0)
4 + sum((x.val for x in bar), 0)
5 |
  |
note: This is an unsafe fix and may change runtime behavior

C419 [*] Unnecessary list comprehension
  --> C419_1.py:14:5
   |
12 |   # Multi-line
13 |   sum(
14 | /     [
15 | |         delta
16 | |         for delta in timedelta_list
17 | |         if delta
18 | |     ],
   | |_____^
19 |       dt.timedelta(),
20 |   )
   |
help: Remove unnecessary comprehension
   |
13 | sum(
   -     [
14 +     (
15 |         delta
16 |         for delta in timedelta_list
17 |         if delta
   -     ],
18 +     ),
19 |     dt.timedelta(),
   |
note: This is an unsafe fix and may change runtime behavior
