Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1480

python: remove tabs, adjust whitespace and address PEP8 warnings

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 0.9
    • Python - Library
    • 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:

      1. "indentation is not a multiple of four" for most files (no biggie)
      2. "multiple spaces before operator" in Thrift.py for the TTypes class constants

      The unit tests all pass with this patch.

      Attachments

        1. THRIFT-1480-pep8ify-v1.patch
          59 kB
          Will Pierce

        Activity

          People

            willp Will Pierce
            willp Will Pierce
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: