Collection Builtin To Comprehension

Python pattern

Use list, set or dictionary comprehensions directly instead of calling list(), dict() or set().

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)