The following code all creates unnecessary list comprehensions
a = all([i is not None for i in range(10)])
b = tuple([i * 2 for i in range(10)])
c = sum([i * 2 for i in range(10)])
d = ",".join([str(i * 2) for i in range(10)])
ruff will only suggest changes on the first line:
stuff.py:3:13: C419 Unnecessary list comprehension
|
2 | def main() -> None:
3 | a = all([i is not None for i in range(10)])
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C419
4 | b = tuple([i * 2 for i in range(10)])
5 | c = sum([i * 2 for i in range(10)])
|
= help: Remove unnecessary list comprehension
However all of these are unnecessary list comprehensions. It ought to be able to identify them all. For one, the docs suggest that sum is covered, but from the above, it appears to not fully be.
The following code all creates unnecessary list comprehensions
ruff will only suggest changes on the first line:
However all of these are unnecessary list comprehensions. It ought to be able to identify them all. For one, the docs suggest that
sumis covered, but from the above, it appears to not fully be.