This rule raises an issue when a comprehension is used to only copy a collection. Instead, the respective constructor should be used.
Python comprehensions are a concise way to create new collections while transforming or filtering elements. However, using a comprehension that copies elements from one collection to another without any transformation is less readable than using the respective constructor directly.
Therefore, when a comprehension is only copying elements, use the appropriate constructor instead:
[x for x in iterable] with list(iterable) {x for x in iterable} with set(iterable) {k: v for k, v in iterable.items()} with dict(iterable) Replace comprehensions that copy elements from one collection to another with the respective constructor.
some_list = [1, 2, 3, 2] [x for x in some_list] # Noncompliant
some_list = [1, 2, 3, 2] list(some_list) # Compliant