Use list, set or dictionary comprehensions directly instead of calling list()
, dict()
or set()
.
Apply with the Grit CLI
grit apply collection_builtin
Collection builtin to comprehension
BEFORE
squares = list(x * x for x in y) squares = set(x * x for x in y) squares = dict((x, x * x) for x in xs) squares = any(x * x for x in y)
AFTER
squares = [x * x for x in y] squares = {x * x for x in y} squares = {x: x * x for x in xs} squares = any(x * x for x in y)