---
source: crates/ruff_linter/src/rules/flake8_comprehensions/mod.rs
---
C416 [*] Unnecessary list comprehension (rewrite using `list()`)
 --> C416.py:6:1
  |
4 | d = {"a": 1, "b": 2, "c": 3}
5 |
6 | [i for i in x]
  | ^^^^^^^^^^^^^^
7 | {i for i in x}
8 | {k: v for k, v in y}
  |
help: Rewrite using `list()`
  |
5 |
  - [i for i in x]
6 + list(x)
7 | {i for i in x}
  |
note: This is an unsafe fix and may change runtime behavior

C416 [*] Unnecessary set comprehension (rewrite using `set()`)
 --> C416.py:7:1
  |
6 | [i for i in x]
7 | {i for i in x}
  | ^^^^^^^^^^^^^^
8 | {k: v for k, v in y}
9 | {k: v for k, v in d.items()}
  |
help: Rewrite using `set()`
  |
6 | [i for i in x]
  - {i for i in x}
7 + set(x)
8 | {k: v for k, v in y}
  |
note: This is an unsafe fix and may change runtime behavior

C416 [*] Unnecessary dict comprehension (rewrite using `dict()`)
  --> C416.py:8:1
   |
 6 | [i for i in x]
 7 | {i for i in x}
 8 | {k: v for k, v in y}
   | ^^^^^^^^^^^^^^^^^^^^
 9 | {k: v for k, v in d.items()}
10 | [(k, v) for k, v in d.items()]
   |
help: Rewrite using `dict()`
  |
7 | {i for i in x}
  - {k: v for k, v in y}
8 + dict(y)
9 | {k: v for k, v in d.items()}
  |
note: This is an unsafe fix and may change runtime behavior

C416 [*] Unnecessary dict comprehension (rewrite using `dict()`)
  --> C416.py:9:1
   |
 7 | {i for i in x}
 8 | {k: v for k, v in y}
 9 | {k: v for k, v in d.items()}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 | [(k, v) for k, v in d.items()]
11 | [(k, v) for [k, v] in d.items()]
   |
help: Rewrite using `dict()`
   |
8  | {k: v for k, v in y}
   - {k: v for k, v in d.items()}
9  + dict(d.items())
10 | [(k, v) for k, v in d.items()]
   |
note: This is an unsafe fix and may change runtime behavior

C416 [*] Unnecessary list comprehension (rewrite using `list()`)
  --> C416.py:10:1
   |
 8 | {k: v for k, v in y}
 9 | {k: v for k, v in d.items()}
10 | [(k, v) for k, v in d.items()]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 | [(k, v) for [k, v] in d.items()]
12 | {k: (a, b) for k, (a, b) in d.items()}
   |
help: Rewrite using `list()`
   |
9  | {k: v for k, v in d.items()}
   - [(k, v) for k, v in d.items()]
10 + list(d.items())
11 | [(k, v) for [k, v] in d.items()]
   |
note: This is an unsafe fix and may change runtime behavior

C416 [*] Unnecessary list comprehension (rewrite using `list()`)
  --> C416.py:11:1
   |
 9 | {k: v for k, v in d.items()}
10 | [(k, v) for k, v in d.items()]
11 | [(k, v) for [k, v] in d.items()]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12 | {k: (a, b) for k, (a, b) in d.items()}
   |
help: Rewrite using `list()`
   |
10 | [(k, v) for k, v in d.items()]
   - [(k, v) for [k, v] in d.items()]
11 + list(d.items())
12 | {k: (a, b) for k, (a, b) in d.items()}
   |
note: This is an unsafe fix and may change runtime behavior

C416 [*] Unnecessary list comprehension (rewrite using `list()`)
  --> C416.py:25:70
   |
24 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196
25 | any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType])
   |                                                                      ^^^^^^^^^^^^^^^^^^^^^^^
26 |
27 | zz = [[1], [2], [3]]
   |
help: Rewrite using `list()`
   |
24 | # Regression test for: https://github.com/astral-sh/ruff/issues/7196
   - any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in[t for t in SymbolType])
25 + any(len(symbol_table.get_by_type(symbol_type)) > 0 for symbol_type in list(SymbolType))
26 |
   |
note: This is an unsafe fix and may change runtime behavior
