HomePhabricator

[python linting] enforce all flake8 E & W codes besides some exceptions

Description

[python linting] enforce all flake8 E & W codes besides some exceptions

Summary:
This enforces all pycodestyle rules aside from the ones we currently
violate.

Current violations (some of these can be fixed fairly soon,
some are super prevalent)

E265 	Block comment should start with '# '
E501 	Line too long (82 > 79 characters)
E704 	Multiple statements on one line (def)
E712 	Comparison to true should be 'if cond is true:' or 'if cond:'
E713 	Test for membership should be 'not in'
E722 	do not use bare except
E731 	Do not assign a lambda expression, use a def
W503 	Line break occurred before a binary operator
W504 	Line break occurred after a binary operator

More about rules:
https://www.flake8rules.com/
https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
https://github.com/PyCQA/pycodestyle/blob/master/CHANGES.txt

These rules aren't often added and if we do get new rules causing issues,
they can be added as exceptions. Note that flake8 is fine if we tell it
to ignore a rule that it doesn't know about.

Flake8 min version has been bumped to 3.0 to support the simultaneous
--select and --ignore. I am guessing most of us are at least on 3.2.1
(ubuntu bionic / debian 9). I've tested on a variety of python / flake8
combinations and the seem to be agreeing that we are clean.
https://flake8.pycqa.org/en/latest/user/violations.html#selecting-and-ignoring-simultaneously-for-fun-and-profit

Depends on D5194 D5197

Test Plan:

arc lint --everything

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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