HomePhabricator

[lint] require plugin flake8-comprehensions

Description

[lint] require plugin flake8-comprehensions

Summary:
See https://pypi.org/project/flake8-comprehensions/ for a list of rules and examples.

To see the list of errors that this diff fixes, run the following commands (on master):

pip install flake8-comprehensions
flake8 --select=C .

Note that in some cases it is required to convert a set/list/dict into a comprehensions (set(int(h, 16) for h in hashes) -> {int(h, 16) for h in hashes}) (error codes C400-404), and in some cases the opposite conversion makes more sense ({h for h in hashes} -> set(hashes)) (C416).

Depends on D13646

Test Plan:

arc lint --everything
ninja check-functional-extended
ninja bench-bitcoin
ninja check
contrib/devtools/circular-dependencies.py

I checked also that the most recent version of flake8-comprehensions and version 3.7.0 (most recent version still supporting python 3.6) are not incompatible, by running flake8 --select=C after installing flake8-comprehensions==3.7.0 after this diff and checking that no other error is raised.

I also checked that arc lint fails if the plugin is missing, with an error message that makes sense.

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D13647

Details

Provenance
PiRKAuthored on Apr 9 2023, 18:04
PiRKPushed on Apr 10 2023, 09:58
Reviewer
Restricted Project
Differential Revision
D13647: [lint] require plugin flake8-comprehensions
Parents
rABC1add51d5cb83: [lint] bump flake8 to >5
Branches
Unknown
Tags
Unknown