Page MenuHomePhabricator

[lint] run mypy on contrib
ClosedPublic

Authored by PiRK on Apr 8 2023, 15:10.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCbd0a8f9bf76f: [lint] run mypy on contrib
Summary

In most cases, the errors are fixed by simply adding a typehint. In one case, initializing a variable with 0. (float) instead of 0 (int) is necessary. In another case, I had to check that a variable really is a list before accessing one of its value by index.

In the case of raise UnicodeDecodeError, mypy found an actual bug.

>>> raise UnicodeDecodeError
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: function takes exactly 5 arguments (0 given)

Rather than figuring out what the 5 arguments should be, it is simpler (and cleaner) to raise and catch a custom error for that particular case.

I skipped contrib/macdeploy, because this module has some hairy errors. It can always be linted in a separate diff in the future.

Depends on D13637

Test Plan

arc lint --everything

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable