---
source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs
---
C400.py:2:13: C400 [*] Unnecessary generator (rewrite as a `list` comprehension)
  |
1 | # Cannot combine with C416. Should use list comprehension here.
2 | even_nums = list(2 * x for x in range(3))
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C400
3 | odd_nums = list(
4 |     2 * x + 1 for x in range(3)
  |
  = help: Rewrite as a `list` comprehension

ℹ Unsafe fix
1 1 | # Cannot combine with C416. Should use list comprehension here.
2   |-even_nums = list(2 * x for x in range(3))
  2 |+even_nums = [2 * x for x in range(3)]
3 3 | odd_nums = list(
4 4 |     2 * x + 1 for x in range(3)
5 5 | )

C400.py:3:12: C400 [*] Unnecessary generator (rewrite as a `list` comprehension)
  |
1 |   # Cannot combine with C416. Should use list comprehension here.
2 |   even_nums = list(2 * x for x in range(3))
3 |   odd_nums = list(
  |  ____________^
4 | |     2 * x + 1 for x in range(3)
5 | | )
  | |_^ C400
  |
  = help: Rewrite as a `list` comprehension

ℹ Unsafe fix
1 1 | # Cannot combine with C416. Should use list comprehension here.
2 2 | even_nums = list(2 * x for x in range(3))
3   |-odd_nums = list(
  3 |+odd_nums = [
4 4 |     2 * x + 1 for x in range(3)
5   |-)
  5 |+]
6 6 | 
7 7 | 
8 8 | # Short-circuit case, combine with C416 and should produce x = list(range(3))

C400.py:9:5: C400 [*] Unnecessary generator (rewrite using `list()`)
   |
 8 | # Short-circuit case, combine with C416 and should produce x = list(range(3))
 9 | x = list(x for x in range(3))
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ C400
10 | x = list(
11 |     x for x in range(3)
   |
   = help: Rewrite using `list()`

ℹ Unsafe fix
6  6  | 
7  7  | 
8  8  | # Short-circuit case, combine with C416 and should produce x = list(range(3))
9     |-x = list(x for x in range(3))
   9  |+x = list(range(3))
10 10 | x = list(
11 11 |     x for x in range(3)
12 12 | )

C400.py:10:5: C400 [*] Unnecessary generator (rewrite using `list()`)
   |
 8 |   # Short-circuit case, combine with C416 and should produce x = list(range(3))
 9 |   x = list(x for x in range(3))
10 |   x = list(
   |  _____^
11 | |     x for x in range(3)
12 | | )
   | |_^ C400
13 |   
14 |   # Not built-in list.
   |
   = help: Rewrite using `list()`

ℹ Unsafe fix
7  7  | 
8  8  | # Short-circuit case, combine with C416 and should produce x = list(range(3))
9  9  | x = list(x for x in range(3))
10    |-x = list(
11    |-    x for x in range(3)
12    |-)
   10 |+x = list(range(3))
13 11 | 
14 12 | # Not built-in list.
15 13 | def list(*args, **kwargs):
