Page MenuHomePhabricator

[lint] require plugin flake8-comprehensions
ClosedPublic

Authored by PiRK on Apr 10 2023, 08:27.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCce5c405077ce: [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.

Event Timeline

PiRK requested review of this revision.Apr 10 2023, 08:27
PiRK removed a reviewer: Restricted Project.
test/functional/test_runner.py
698 ↗(On Diff #39459)

I checked that returning a set works the same way as returning a list in all callsites. This change in the function signature save a set -> list conversion.

This revision is now accepted and ready to land.Apr 10 2023, 09:34
This revision was automatically updated to reflect the committed changes.