Page MenuHomePhabricator

[python linting] enforce E722: do not use bare except
ClosedPublic

Authored by markblundeberg on Feb 7 2020, 17:38.

Details

Summary

Generally using except: is a mistake since it catches everything
including SystemExit / KeyboardInterrupt / etc.... When we really
do want such a catch we should explicitly use except BaseException:,
otherwise we normally want except Exception: or even better, name
the specific exception that might occur.

Depends on D5204 D5206

Test Plan
arc lint --everything
ninja check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markblundeberg created this revision.Feb 7 2020, 17:38
Herald added a reviewer: Restricted Project. · View Herald TranscriptFeb 7 2020, 17:38
markblundeberg edited the summary of this revision. (Show Details)Feb 7 2020, 17:47
markblundeberg added inline comments.Feb 7 2020, 17:50
test/functional/rpc_preciousblock.py
18 ↗(On Diff #16135)

I'm still not quite sure why this loop is made like this, or what exactly it is catching.

test/functional/test_framework/test_framework.py
323 ↗(On Diff #16135)

Probably the only place we want to have keyboard interrupts being caught... I think.

markblundeberg added inline comments.Feb 7 2020, 17:58
.arclint
29 ↗(On Diff #16135)

The remaining four are:

E501 	Line too long (82 > 79 characters)
E704 	Multiple statements on one line (def)
W503 	Line break occurred before a binary operator
W504 	Line break occurred after a binary operator

They have a bunch of violations and in fact the latter three are not even enabled by default in flake8.

This is about as far as we can get with the low hanging fruit.

deadalnix accepted this revision.Feb 7 2020, 18:03
This revision is now accepted and ready to land.Feb 7 2020, 18:03