Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More linting #262

Merged
merged 9 commits into from
Jan 16, 2023
Merged

More linting #262

merged 9 commits into from
Jan 16, 2023

Conversation

PiRK
Copy link
Collaborator

@PiRK PiRK commented Jan 12, 2023

Fix as many flake8 errors as possible, so that the tool can be run without ignoring anything.

Addresses #252

BaseException is the base class for all builtin exceptions, including stuff like SystemExit and KeyboardInterrupt. It is rarely a good idea to catch those. This is equivalent to bare except clauses (see next commit)
The official python documentation explicitely says to not directly inherit this for custom exceptions, but inherit Exception instead.

When it comes to explicitely raising an error, RuntimeError is generic enough and can be caught with a generic `except Exception`.
I did this semi-automatically by just replacing bare exceptions with `except Exception`. It is still awful, but at least we no longer catch `KeyboardInterrupt` and `SystemExit`.

Fixing this properly would take an enormous amount of work, understanding each one of the 100+ occurences to guess the correct exceptions to catch. This will have to be done the slow way, each occurence at a time when the code is touched for another reason.
This improves the code formatting by black
This is explicitely prohibited by PEP 484
Focus on the longest comments that are most likely to cause problems with black formatting.
@PiRK PiRK merged commit 470dd86 into Bitcoin-ABC:master Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant