Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
Patch Available
Description
The python library files have some inconsistencies (different indent levels and docstring placement) and the pep8 linter produces dozens of warnings. There are also several places where tabs are used instead of spaces, which is not good.
This patch addresses almost all of the pep8 issues with as little modification of the code as possible.
This patch:
- converts 3 instances of tabs into the correct number of spaces
- removes unnecessary trailing semicolons and backslashes
- changes None comparisons to be identity based, 'x != None' becomes 'x is not None' in a handful of places
- removes unnecessary '== True' in one if statement
- wraps lines at 80 characters and removes trailing whitespace
- corrects a handful of grammar problems in docstrings (mostly to help with 80 char line wrap)
- converts all the docstrings to use """ (instead of ''' or ") and makes placement consistent
- fixes pep8 warnings about missing spaces around operators, e.g. (a-b) becomes (a - b)
- adjusts ordering of stdlib imports to be alphabetical (could be better still)
- correct internal indent depths of methods when they switch from 2 to 4 spaces
There's a mix of files that use 4-spaces for indentation, versus the majority which use 2-spaces for indentation. This patch doesn't change that. I wanted to get the code as pep8 clean as possible and touch as few lines as possible to get it there. The TType constants defined in Thrift.py have some nice vertical whitespace that isn't pep8-happy, but it looked too clean to touch so I left it unchanged.
After this patch, the pep8 utility only reports two warnings:
- "indentation is not a multiple of four" for most files (no biggie)
- "multiple spaces before operator" in Thrift.py for the TTypes class constants
The unit tests all pass with this patch.