Repository navigation
Enforce ruff/flake8-comprehensions rules (C4) - #4785
DimitriPapadopoulos wants to merge 9 commits into
Conversation
|
|
1 similar comment
|
|
bf51fe7 to
1ea7c2c
Compare
|
I think you'll want to enable allow-dict-calls-with-keyword-arguments |
bb995d6 to
5e77363
Compare
|
After adding allow-dict-calls-with-keyword-arguments, most occurrences of C408 have disappeared. A few instances of |
|
I personally think those make sense, it's mainly changing generators of tuples into dict comprehensions. |
ef18ee2 to
e525809
Compare
412819f to
36fa684
Compare
|
Rebased. |
|
|
I'm not sure your rebase is correct. I see refurb related changes and the change PyPy tests have also been flaky: #4940 |
|
I had to rerun |
|
Reapplied |
051b475 to
4152840
Compare
619ff6f to
e714379
Compare
C400 Unnecessary generator (rewrite as a `list` comprehension)
C401 Unnecessary generator (rewrite as a `set` comprehension)
C402 Unnecessary generator (rewrite as a `dict` comprehension)
C408 Unnecessary `dict()` call (rewrite as a literal) C405 Unnecessary `list` literal (rewrite as a `set` literal)
C413 Unnecessary `list` call around `sorted()`
C414 Unnecessary `list` call within `sorted()`
C417 Unnecessary `map` usage (rewrite using a generator expression)
C420 Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
Updates style to match Ruff 0.16 rules.
Retain the dict(a=1) call style as an elegant alternative to string-keyed literals rather than have Ruff 0.16's new default rewrite it. Ref jaraco/skeleton#210. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Switch from ignoring C408 (unnecessary-collection-call) entirely to enabling flake8-comprehensions allow-dict-calls-with-keyword-arguments, which retains the preferred dict(a=1) keyword-call style while C408 still flags dict() and dict([...]). Suggested by @Avasam; matches the configuration in pypa/setuptools#4785. Ref #210. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Summary of changes
Pull Request Checklist
newsfragments/.(See documentation for details)