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

pull practicalswift wants to merge 2 commits into bitcoin:master from practicalswift:enable-flake8-checks changing 22 files +69 −51
  1. practicalswift commented at 11:02 AM on April 15, 2018: 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 .
    $
    
  2. fanquake added the label Scripts and tools on Apr 15, 2018
  3. practicalswift renamed this:
    tests/python: Enable additional Python flake8 rules for automatic linting via Travis
    tests/scripts: Enable additional Python flake8 rules for automatic linting via Travis
    on Apr 15, 2018
  4. practicalswift renamed this:
    tests/scripts: Enable additional Python flake8 rules for automatic linting via Travis
    tests/tools: Enable additional Python flake8 rules for automatic linting via Travis
    on Apr 15, 2018
  5. practicalswift force-pushed on Apr 15, 2018
  6. practicalswift force-pushed on Apr 15, 2018
  7. in contrib/linearize/linearize-data.py:35 in 41caac9bec outdated
      31 | @@ -32,7 +32,7 @@ def uint32(x):
      32 |  
      33 |  def bytereverse(x):
      34 |  	return uint32(( ((x) << 24) | (((x) << 8) & 0x00ff0000) |
      35 | -		       (((x) >> 8) & 0x0000ff00) | ((x) >> 24) ))
      36 | +		(((x) >> 8) & 0x0000ff00) | ((x) >> 24) ))
    


    MarcoFalke commented at 11:54 AM on April 15, 2018:

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


    practicalswift commented at 12:07 PM on April 15, 2018:

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

  8. in contrib/linearize/linearize-data.py:227 in 41caac9bec outdated
     223 | @@ -224,7 +224,7 @@ def run(self):
     224 |  			inExtent = BlockExtent(self.inFn, self.inF.tell(), inhdr, blk_hdr, inLen)
     225 |  
     226 |  			self.hash_str = calc_hash_str(blk_hdr)
     227 | -			if not self.hash_str in blkmap:
     228 | +			if self.hash_str not in blkmap:
    


    MarcoFalke commented at 11:54 AM on April 15, 2018:

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

  9. in contrib/linearize/linearize-hashes.py:44 in 41caac9bec outdated
      42 | +				{'Authorization': self.authhdr,
      43 | +				'Content-type': 'application/json'})
      44 |  		except ConnectionRefusedError:
      45 |  			print('RPC connection refused. Check RPC settings and the server status.',
      46 | -			      file=sys.stderr)
      47 | +				file=sys.stderr)
    


    MarcoFalke commented at 11:56 AM on April 15, 2018:

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

  10. practicalswift force-pushed on Apr 15, 2018
  11. MarcoFalke changes_requested
  12. MarcoFalke commented at 11:57 AM on April 15, 2018: member

    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.

  13. practicalswift force-pushed on Apr 15, 2018
  14. practicalswift force-pushed on Apr 15, 2018
  15. practicalswift commented at 4:25 PM on April 15, 2018: contributor

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

  16. MarcoFalke commented at 4:42 PM on April 15, 2018: 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".

  17. practicalswift commented at 4:54 PM on April 15, 2018: contributor

    @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? :-)

  18. MarcoFalke commented at 5:19 PM on April 15, 2018: 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)

  19. practicalswift force-pushed on Apr 16, 2018
  20. practicalswift commented at 7:01 AM on April 16, 2018: contributor

    @MarcoFalke Updated! Please re-review :-)

  21. practicalswift force-pushed on Apr 16, 2018
  22. practicalswift force-pushed on Apr 16, 2018
  23. practicalswift force-pushed on Apr 16, 2018
  24. in test/functional/test_framework/authproxy.py:44 in 3b7e497612 outdated
      40 | @@ -41,6 +41,7 @@
      41 |  import socket
      42 |  import time
      43 |  import urllib.parse
      44 | +from exceptions import BrokenPipeError, ConnectionResetError
    


    fanquake commented at 8:47 AM on April 16, 2018:
        from exceptions import BrokenPipeError, ConnectionResetError
    ImportError: No module named 'exceptions'
    
  25. practicalswift force-pushed on Apr 16, 2018
  26. in contrib/linearize/linearize-hashes.py:24 in 21cc7ddc04 outdated
      20 | @@ -21,7 +21,7 @@
      21 |  
      22 |  settings = {}
      23 |  
      24 | -##### Switch endian-ness #####
      25 | +# Switch endian-ness
    


    MarcoFalke commented at 12:01 PM on April 16, 2018:

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

  27. MarcoFalke commented at 12:04 PM on April 16, 2018: member

    utACK 21cc7ddc0406ee3c76623e7f23dbbcd2d0b6f241

  28. practicalswift force-pushed on Apr 16, 2018
  29. practicalswift force-pushed on Apr 16, 2018
  30. practicalswift commented at 12:32 PM on April 16, 2018: contributor

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

  31. MarcoFalke commented at 1:15 PM on April 16, 2018: member

    re-utACK bf0d779

  32. practicalswift force-pushed on Apr 16, 2018
  33. jnewbery commented at 2:51 PM on April 16, 2018: member

    utACK 96455458ab3f7183141eb64d6e7c3abe11c7a355. Seems like useful cleanup.

  34. MarcoFalke commented at 3:19 PM on April 16, 2018: member

    Please fixup the travis failure.

  35. Minor Python cleanups to make flake8 pass with the new rules enabled f020aca297
  36. Enable additional flake8 rules 643aad17fa
  37. practicalswift force-pushed on Apr 16, 2018
  38. practicalswift commented at 3:41 PM on April 16, 2018: contributor

    @MarcoFalke Thanks for the ping! Fixed!

    Please re-review :-)

  39. jnewbery commented at 3:45 PM on April 16, 2018: member

    utACK 643aad17faf104510ba123b596676256f26549c2

  40. MarcoFalke merged this on Apr 16, 2018
  41. MarcoFalke closed this on Apr 16, 2018

  42. MarcoFalke referenced this in commit fe8fa22d7a on Apr 16, 2018
  43. PastaPastaPasta referenced this in commit 7d8135058a on Jul 19, 2020
  44. PastaPastaPasta referenced this in commit 17acd6b472 on Jul 22, 2020
  45. practicalswift deleted the branch on Apr 10, 2021
  46. gades referenced this in commit 16d9b4857a on Mar 8, 2022
  47. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me