Skip to content

tests/tools: Enable additional Python flake8 rules for automatic linting via Travis#12987

Merged
maflcko merged 2 commits into
bitcoin:masterfrom
practicalswift:enable-flake8-checks
Apr 16, 2018
Merged

tests/tools: Enable additional Python flake8 rules for automatic linting via Travis#12987
maflcko merged 2 commits into
bitcoin:masterfrom
practicalswift:enable-flake8-checks

Conversation

@practicalswift

@practicalswift practicalswift commented Apr 15, 2018

Copy link
Copy Markdown
Contributor

Enabled rules:

* E242: tab after ','
* E266: too many leading '#' for block comment
* E401: multiple imports on one line
* E402: module level import not at top of file
* E701: multiple statements on one line (colon)
* E901: SyntaxError: invalid syntax
* E902: TokenError: EOF in multi-line string
* F821: undefined name 'Foo'
* W293: blank line contains whitespace
* W606: 'async' and 'await' are reserved keywords starting with Python 3.7

Note to reviewers:

  • In general we don't allow whitespace cleanups to existing code, but in order to allow for enabling Travis checking for these rules a few smaller whitespace cleanups had to made as part of this PR.
  • Use this ?w=1 link to show a diff without whitespace changes.

Before this commit:

$ flake8 -qq --statistics --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
5     E266 too many leading '#' for block comment
4     E401 multiple imports on one line
6     E402 module level import not at top of file
5     E701 multiple statements on one line (colon)
1     F812 list comprehension redefines 'n' from line 159
4     F821 undefined name 'ConnectionRefusedError'
28    W293 blank line contains whitespace

After this commit:

$ flake8 -qq --statistics --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
$

@practicalswift practicalswift changed the title tests/python: Enable additional Python flake8 rules for automatic linting via Travis tests/scripts: Enable additional Python flake8 rules for automatic linting via Travis Apr 15, 2018
@practicalswift practicalswift changed the title tests/scripts: Enable additional Python flake8 rules for automatic linting via Travis tests/tools: Enable additional Python flake8 rules for automatic linting via Travis Apr 15, 2018
@practicalswift practicalswift force-pushed the enable-flake8-checks branch 3 times, most recently from 41caac9 to 2757516 Compare April 15, 2018 11:57

@maflcko maflcko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am fine with removing the trailing white space, since that is now enforced for a couple of months. Though, I don't like to enforce strict rules on leading white space or statements that are otherwise identical.

Comment thread contrib/linearize/linearize-data.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nack. There is no way we can force everyone to configure their editor in this specific way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've now reverted this change and the corresponding rule (E101: indentation contains mixed spaces and tabs).

Comment thread contrib/linearize/linearize-data.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Those seem identical. No reason to enforce either and forbid the other.

Comment thread contrib/linearize/linearize-hashes.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here and the hunk above. (No way we can force everyone to configure their editors to behave this way)

@practicalswift practicalswift force-pushed the enable-flake8-checks branch 2 times, most recently from 53fc83b to 10fd16d Compare April 15, 2018 16:12
@practicalswift

Copy link
Copy Markdown
Contributor Author

@MarcoFalke Thanks for reviewing. Good feedback! Now updated. Please re-review :-)

@maflcko

maflcko commented Apr 15, 2018

Copy link
Copy Markdown
Member

Other than W293, I'd drop all those that seem to enforce white space in a specific way. I'd rather avoid being extra strict on everyone and prescribe exactly how to use whitespace "properly".

@practicalswift

Copy link
Copy Markdown
Contributor Author

@MarcoFalke Thanks for clarifying!

Of the whitespace related rule changes these can be divided into 1.) indentation related and 2.) related to whitespace around operators.

Indentation related:

1     E121 continuation line under-indented for hanging indent
1     E123 closing bracket does not match indentation of opening bracket's line
1     E124 closing bracket does not match visual indentation
2     E126 continuation line over-indented for hanging indent
1     E129 visually indented line with same indent as next logical line

Related to whitespace around operators:

7     E222 multiple spaces after operator
4     E228 missing whitespace around modulo operator

Do you want to get rid of all rules above, or only the indentation related? :-)

@maflcko

maflcko commented Apr 15, 2018

Copy link
Copy Markdown
Member

Personally, I'd prefer to get rid of all of them for now. (If you or someone else feels strongly about them, they can put them in a separate pull request)

@practicalswift

Copy link
Copy Markdown
Contributor Author

@MarcoFalke Updated! Please re-review :-)

@practicalswift practicalswift force-pushed the enable-flake8-checks branch 3 times, most recently from 4bdfc30 to 3b7e497 Compare April 16, 2018 07:58

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

    from exceptions import BrokenPipeError, ConnectionResetError
ImportError: No module named 'exceptions'

Comment thread contrib/linearize/linearize-hashes.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might as well remove the whole lines, since they are redundant.

@maflcko

maflcko commented Apr 16, 2018

Copy link
Copy Markdown
Member

utACK 21cc7ddc0406ee3c76623e7f23dbbcd2d0b6f241

@practicalswift practicalswift force-pushed the enable-flake8-checks branch 2 times, most recently from a30b48d to bf0d779 Compare April 16, 2018 12:16
@practicalswift

Copy link
Copy Markdown
Contributor Author

@MarcoFalke Updated! Please re-re-review :-)

@maflcko

maflcko commented Apr 16, 2018

Copy link
Copy Markdown
Member

re-utACK bf0d779

@jnewbery

Copy link
Copy Markdown
Contributor

utACK 96455458ab3f7183141eb64d6e7c3abe11c7a355. Seems like useful cleanup.

@maflcko

maflcko commented Apr 16, 2018

Copy link
Copy Markdown
Member

Please fixup the travis failure.

@practicalswift

practicalswift commented Apr 16, 2018

Copy link
Copy Markdown
Contributor Author

@MarcoFalke Thanks for the ping! Fixed!

Please re-review :-)

@jnewbery

Copy link
Copy Markdown
Contributor

utACK 643aad1

@maflcko maflcko merged commit 643aad1 into bitcoin:master Apr 16, 2018
maflcko pushed a commit that referenced this pull request Apr 16, 2018
…automatic linting via Travis

643aad1 Enable additional flake8 rules (practicalswift)
f020aca Minor Python cleanups to make flake8 pass with the new rules enabled (practicalswift)

Pull request description:

  Enabled rules:

  ```
  * E242: tab after ','
  * E266: too many leading '#' for block comment
  * E401: multiple imports on one line
  * E402: module level import not at top of file
  * E701: multiple statements on one line (colon)
  * E901: SyntaxError: invalid syntax
  * E902: TokenError: EOF in multi-line string
  * F821: undefined name 'Foo'
  * W293: blank line contains whitespace
  * W606: 'async' and 'await' are reserved keywords starting with Python 3.7
  ```

  Note to reviewers:
  * In general we don't allow whitespace cleanups to existing code, but in order to allow for enabling Travis checking for these rules a few smaller whitespace cleanups had to made as part of this PR.
  * Use [this `?w=1` link](https://github.com/bitcoin/bitcoin/pull/12987/files?w=1) to show a diff without whitespace changes.

  Before this commit:

  ```
  $ flake8 -qq --statistics --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
  5     E266 too many leading '#' for block comment
  4     E401 multiple imports on one line
  6     E402 module level import not at top of file
  5     E701 multiple statements on one line (colon)
  1     F812 list comprehension redefines 'n' from line 159
  4     F821 undefined name 'ConnectionRefusedError'
  28    W293 blank line contains whitespace
  ```

  After this commit:

  ```
  $ flake8 -qq --statistics --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
  $
  ```

Tree-SHA512: fc7d5e752298a50d4248afc620ee2c173135b4ca008e48e02913ac968e5a24a5fd5396926047ec62f1d580d537434ccae01f249bb2f3338fa59dc630bf97ca7a
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jul 22, 2020
…es for automatic linting via Travis

643aad1 Enable additional flake8 rules (practicalswift)
f020aca Minor Python cleanups to make flake8 pass with the new rules enabled (practicalswift)

Pull request description:

  Enabled rules:

  ```
  * E242: tab after ','
  * E266: too many leading '#' for block comment
  * E401: multiple imports on one line
  * E402: module level import not at top of file
  * E701: multiple statements on one line (colon)
  * E901: SyntaxError: invalid syntax
  * E902: TokenError: EOF in multi-line string
  * F821: undefined name 'Foo'
  * W293: blank line contains whitespace
  * W606: 'async' and 'await' are reserved keywords starting with Python 3.7
  ```

  Note to reviewers:
  * In general we don't allow whitespace cleanups to existing code, but in order to allow for enabling Travis checking for these rules a few smaller whitespace cleanups had to made as part of this PR.
  * Use [this `?w=1` link](https://github.com/bitcoin/bitcoin/pull/12987/files?w=1) to show a diff without whitespace changes.

  Before this commit:

  ```
  $ flake8 -qq --statistics --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
  5     E266 too many leading '#' for block comment
  4     E401 multiple imports on one line
  6     E402 module level import not at top of file
  5     E701 multiple statements on one line (colon)
  1     F812 list comprehension redefines 'n' from line 159
  4     F821 undefined name 'ConnectionRefusedError'
  28    W293 blank line contains whitespace
  ```

  After this commit:

  ```
  $ flake8 -qq --statistics --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
  $
  ```

Tree-SHA512: fc7d5e752298a50d4248afc620ee2c173135b4ca008e48e02913ac968e5a24a5fd5396926047ec62f1d580d537434ccae01f249bb2f3338fa59dc630bf97ca7a
Signed-off-by: pasta <pasta@dashboost.org>
@practicalswift practicalswift deleted the enable-flake8-checks branch April 10, 2021 19:34
gades pushed a commit to cosanta/cosanta-core that referenced this pull request Mar 8, 2022
…es for automatic linting via Travis

643aad1 Enable additional flake8 rules (practicalswift)
f020aca Minor Python cleanups to make flake8 pass with the new rules enabled (practicalswift)

Pull request description:

  Enabled rules:

  ```
  * E242: tab after ','
  * E266: too many leading '#' for block comment
  * E401: multiple imports on one line
  * E402: module level import not at top of file
  * E701: multiple statements on one line (colon)
  * E901: SyntaxError: invalid syntax
  * E902: TokenError: EOF in multi-line string
  * F821: undefined name 'Foo'
  * W293: blank line contains whitespace
  * W606: 'async' and 'await' are reserved keywords starting with Python 3.7
  ```

  Note to reviewers:
  * In general we don't allow whitespace cleanups to existing code, but in order to allow for enabling Travis checking for these rules a few smaller whitespace cleanups had to made as part of this PR.
  * Use [this `?w=1` link](https://github.com/bitcoin/bitcoin/pull/12987/files?w=1) to show a diff without whitespace changes.

  Before this commit:

  ```
  $ flake8 -qq --statistics --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
  5     E266 too many leading '#' for block comment
  4     E401 multiple imports on one line
  6     E402 module level import not at top of file
  5     E701 multiple statements on one line (colon)
  1     F812 list comprehension redefines 'n' from line 159
  4     F821 undefined name 'ConnectionRefusedError'
  28    W293 blank line contains whitespace
  ```

  After this commit:

  ```
  $ flake8 -qq --statistics --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
  $
  ```

Tree-SHA512: fc7d5e752298a50d4248afc620ee2c173135b4ca008e48e02913ac968e5a24a5fd5396926047ec62f1d580d537434ccae01f249bb2f3338fa59dc630bf97ca7a
Signed-off-by: pasta <pasta@dashboost.org>
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants