unnecessary-comprehension (C416)#
Derived from the flake8-comprehensions linter.
Autofix is always available.
What it does#
Checks for unnecessary dict
, list
, and set
comprehension.
Why is this bad?#
It's unnecessary to use a dict
/list
/set
comprehension to build a
data structure if the elements are unchanged. Wrap the iterable with
dict()
, list()
, or set()
instead.
Examples#
Use instead: