This is a follow up to Removed unnecessary list() calls on sorted(). by cclauss · Pull Request #17653 · django/django · GitHub which addresses a ruff rule derived from Adam’s own flake8-comprehensions.
I think flake8-comprehensions is great and have started using on most projects now. Seeing as the above PR was accepted, should we address the remaining issues that f8c addresses and add it to the dependency list?
Here are the remaining issues:
django main % (3) flake8 --show-source .
./contrib/gis/management/commands/ogrinspect.py:130:18: C416 Unnecessary list comprehension - rewrite using list().
output = [s for s in _ogrinspect(ds, model_name, **ogr_options)]
^
./core/management/templates.py:121:32: C417 Unnecessary use of map - use a generator expression instead.
extra_files.extend(map(lambda x: x.strip(), file.split(",")))
^
./forms/formsets.py:387:23: C419 Unnecessary list comprehension passed to all() prevents short-circuiting - rewrite as a generator.
forms_valid = all(
^
./forms/formsets.py:579:12: C419 Unnecessary list comprehension passed to all() prevents short-circuiting - rewrite as a generator.
return all([formset.is_valid() for formset in formsets])
^
./template/backends/django.py:116:12: C416 Unnecessary dict comprehension - rewrite using dict().
return {
^
./test/runner.py:1056:36: C401 Unnecessary generator - rewrite as a set comprehension.
suite.serialized_aliases = set(
^
./utils/datastructures.py:322:21: C416 Unnecessary dict comprehension - rewrite using dict().
return repr({key: value for key, value in self._store.values()})