Skip to content

Conversation

achow101
Copy link
Member

@achow101 achow101 commented Sep 5, 2019

Adds support for using the flake8 linter and a travis job that runs it to check for code style and other errors. Also adds a script for using the autopep8 formatter and applies the suggested changes. Both autopep8 and flake8 are added as developer dependencies in pyproject.toml.

Most of the fixes can be done by running an autopep8 command and are indicated as such in the commit message using the scripted-diff format even though scripted diffs aren't actually being checked by travis.

Closes #221
Closes #192

Copy link
Contributor

@jb55 jb55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! TIL autopep...

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6953bc7

Now that there's a lint stage, I'll rebase #203 on top.

---BEGIN-SCRIPTED-DIFF---
autopep8 --select E1 --in-place test/*.py hwilib/*.py hwilib/devices/*.py hwi.py
---END-SCRIPTED-DIFF---
Fixes E2 whitespace errors except for E261 (double space before inline comment)

---BEGIN-SCRIPTED-DIFF---
autopep8 --select E20,E21,E22,E23,E24,E25,E262,E265,E266,E27 --in-place test/*.py hwilib/*.py hwilib/devices/*.py hwi.py
---END-SCRIPTED-DIFF---
Fix E3 blank line errors except for E302 (expected 2 blank lines, found 0)
and E305 (expected 2 blank lines after end of function or class)

---BEGIN-SCRIPTED-DIFF---
autopep8 --select E301,E303,E304,E306 --in-place test/*.py hwilib/*.py hwilib/devices/*.py hwi.py
---END-SCRIPTED-DIFF---
---BEGIN-SCRIPTED-DIFF---
autopep8 --select E4 --in-place test/*.py hwilib/*.py hwilib/devices/*.py hwi.py
---END-SCRIPTED-DIFF---
---BEGIN-SCRIPTED-DIFF---
autopep8 --select E502 --in-place test/*.py hwilib/*.py hwilib/devices/*.py hwi.py
---END-SCRIPTED-DIFF---
---BEGIN-SCRIPTED-DIFF---
autopep8 --select E7 --in-place test/*.py hwilib/*.py hwilib/devices/*.py hwi.py
---END-SCRIPTED-DIFF---
Fixes E711 (comparison to None should be ‘if cond is None:’), E712
(comparison to True should be ‘if cond is True:’ or ‘if cond:’),
and E713 (test for membership should be ‘not in’) errors as
listed by `flake8 --select=E7`
---BEGIN-SCRIPTED-DIFF---
autopep8 --select W --in-place test/*.py hwilib/*.py hwilib/devices/*.py hwi.py
---END-SCRIPTED-DIFF---
Remove or unassign unused variables as listed by `flake8 --select=F841`
Removed everything listed by `flake8 --select=F401`
Fixes F821 undefined name errors as reported by `flake8 --select=F821`
Remove * imports with explicit name imports as listed by `flake8 --select=F403,F405`
@achow101
Copy link
Member Author

achow101 commented Sep 6, 2019

Rebased following merges of #137 and #247

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK d07e102

@practicalswift
Copy link

ACK d07e102 -- diff looks correct

In addition to flake8/autopep8: what about also using black to reduce the degrees of freedom when it comes to DIY formatting?

@achow101
Copy link
Member Author

achow101 commented Sep 7, 2019

In addition to flake8/autopep8: what about also using black to reduce the degrees of freedom when it comes to DIY formatting?

I don't care about formatting that much and IMO black's style is too restrictive.

achow101 added a commit that referenced this pull request Sep 7, 2019
d07e102 Add lint stage that runs flake8 (Andrew Chow)
ecbb847 Add flake8 as a dev dependency (Andrew Chow)
a57754c Add autopep8 as dev dependency and script to run it (Andrew Chow)
ba7e7c0 Fix F403 and F405 star imports (Andrew Chow)
755af90 Fix F821 Undefined name errors (Andrew Chow)
a3bb0a4 Fix F401 Unused import errors (Andrew Chow)
9042e22 Fix F841 local variable is assigned to but never used (Andrew Chow)
709694b Fix W whitespace warnings (Andrew Chow)
6e1afdb Fix E71 errors that autopep8 can't fix automatically (Andrew Chow)
9b60bec Fix E7 statement errors (Andrew Chow)
50afb0c Fix E502 redundant backslashes (Andrew Chow)
1798002 Fix E4 import errors (Andrew Chow)
51182d5 Fix E3 blank line errors (Andrew Chow)
da2dce3 Fix E2 whitespace errors (Andrew Chow)
860c5d3 Fix E1 indentation errors (Andrew Chow)
632d47b Add flake8 configuration (Andrew Chow)

Pull request description:

  Adds support for using the flake8 linter and a travis job that runs it to check for code style and other errors. Also adds a script for using the autopep8 formatter and applies the suggested changes. Both autopep8 and flake8 are added as developer dependencies in pyproject.toml.

  Most of the fixes can be done by running an autopep8 command and are indicated as such in the commit message using the scripted-diff format even though scripted diffs aren't actually being checked by travis.

  Closes #221
  Closes #192

ACKs for top commit:
  practicalswift:
    ACK d07e102 -- diff looks correct
  fanquake:
    re-ACK d07e102

Tree-SHA512: b19c652f754b67c8605c5126ea0498e10512051db8a7815ecb77cb13050ae2bba7d4e3cd5512f47d6ba78432717d915a3f86ae1864f48beab3a3e4ee08ec4a7b
@achow101 achow101 merged commit d07e102 into bitcoin-core:master Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InvalidBase58Error doesn't exist repo: add pyflakes lint checks on pull requests
4 participants