- Drop Python 3.8 support.
- Support Python 3.13.
Add rule C420 to check for dict comprehensions with constant values, encouraging replacement with
dict.fromkeys()
.Thanks to Tom Kuson in PR #553.
- Drop Python 3.7 support.
- Support Python 3.12.
- Add rule C418 to check for calls passing a dict literal or dict comprehension to
dict()
. - Add rule C419 to check for calls passing a list comprehension to
any()
/all()
.
Fix false positives in C406 “unnecessary dict literal”.
Fixes Issue #260.
Expand C416 to
dict
comprehensions.Thanks to Aaron Gokaslan in PR #490.
Fix false positive in rules C402 and C404 for
dict()
calls with keyword arguments.Thanks to Anders Kaseorg for the report in Issue #457.
Add rule C417 which recommends rewriting use of
map()
withlambda
to an equivalent generator expression or comprehension.Thanks to Tushar Sadhwani in PR #409.
- Support Python 3.11.
- Drop Python 3.6 support.
- Remove upper bound on Flake8 version.
- Support Flake8 4.
Fix type hint for
tree
argument.Thanks to kasium for the report in Issue #352.
- Add type hints.
- Support Python 3.10.
- Stop distributing tests to reduce package size. Tests are not intended to be run outside of the tox setup in the repository. Repackagers can use GitHub's tarballs per tag.
Remove rules C407 (Unnecessary
<dict/list>
comprehension -<builtin>
can take a generator) and C412 (Unnecessary<dict/list/set>
comprehension - 'in' can take a generator). Both rules recommended increasing laziness, which is not always desirable and can lead to subtle bugs. Also, a fully exhausted generator is slower than an equivalent comprehension, so the advice did not always improve performance.Thanks to David Smith, Dylan Young, and Leonidas Loucas for the report in Issue #247.
- Drop Python 3.5 support.
- Improved installation instructions in README.
- Support Python 3.9.
- Move license from ISC to MIT License.
- Partially reverted the change to
C408
to make it apply again to whendict
is called with keyword arguments, e.g.dict(a=1, b=2)
will be flagged to be rewritten in the literal form{"a": 1, "b": 2}
- Made
C408
only apply when no arguments are passed todict
/list
/tuple
.
- Remove check for dict comprehensions in rule C407 as it would also change the
results for certain builtins such as
sum()
.
- Remove check for set comprehensions in rule C407 as it would change the
results for certain builtins such as
sum()
.
- Add
filter
andmap
to rule C407. - Check for dict and set comprehensions in rules C407 and C412.
- Remove the tuple/unpacking check from C416 to prevent false positives where the type of the iterable is changed from some iterable to a tuple.
- Ensure the fix for false positives in
C416
rule for asynchronous comprehensions runs on Python 3.6 too.
- Fix false positives in
C416
rule for list comprehensions returning tuples.
- Fix false positives in
C416
rule for asynchronous comprehensions.
- Update Python support to 3.5-3.8.
- Fix false positives for C404 for list comprehensions not directly creating tuples.
- Add
C413
rule that checks for unnecessary use oflist()
orreversed()
aroundsorted()
. - Add
C414
rule that checks for unnecessary use of the following: list()
,reversed()
,sorted()
, ortuple()
withinset
orsorted()
list()
ortuple()
withinlist()
ortuple()
set()
withinset
- Add
- Add
C415
rule that checks for unnecessary reversal of an iterable via subscript withinreversed()
,set()
, orsorted()
. - Add
C416
rule that checks for unnecessary list or set comprehensions that can be rewritten usinglist()
orset()
.
- Fix version display on
flake8 --version
(removing dependency oncached-property
). Thanks to Jon Dufresne.
- Update Flake8 support to 3.0+ only. 3.0.0 was released in 2016 and the plugin hasn't been tested with it since.
- Converted setuptools metadata to configuration file. This meant removing the
__version__
attribute from the package. If you want to inspect the installed version, useimportlib.metadata.version("flake8-comprehensions")
(docs / backport). - Add dependencies on
cached-property
andimportlib-metadata
. - Fix false negatives in
C407
for cases whenenumerate
andsum()
are passed more than one argument.
- Update Python support to 3.5-3.7, as 3.4 has reached its end of life.
C412
rule that complains about using list comprehension within
.
- Add missing builtin
enumerate
toC407
.
- Drop Python 2 support, only Python 3.4+ is supported now.
- Fix false positives in
C408
for calls using*args
or**kwargs
.
- Plugin now reserves the full
C4XX
code space rather than justC40X
C408
rule that complains about usingtuple()
,list()
, ordict()
instead of a literal.C409
andC410
rules that complain about an unnecessary list or tuple that could be rewritten as a literal.C411
rule that complains about using list comprehension inside alist()
call.
- Don't allow installation with Flake8 3.2.0 which doesn't enable the plugin. This bug was fixed in Flake8 3.2.1.
- Prevent false positives of
C402
from generators of expressions that aren't two-tuples. C405
andC406
now also complain about unnecessary tuple literals.
C407
rule that complains about unnecessary list comprehensions inside builtins that can work on generators.
- Split all rule codes by type. This allows granular selection of the rules in flake8 configuration.
- Fix crash on method calls
C401
rule that complains about unnecessary list comprehensions inside calls toset()
ordict()
.C402
rule that complains about unnecessary list literals inside calls toset()
ordict()
.
C400
rule that complains about an unnecessary usage of a generator when a list/set/dict comprehension would do.