Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autopep8 #2632

Merged
merged 3 commits into from
Jan 5, 2013
Merged

Autopep8 #2632

merged 3 commits into from
Jan 5, 2013

Conversation

hayd
Copy link
Contributor

@hayd hayd commented Jan 3, 2013

Used autopep8 to make all of pandas py files more PEP8 compliant (Excluding 230 E501 lines too long (over 80 chars), and 6 changes which had to be reverted to fix test failures - in second commit). See statistics in my comment.

I iterated over every py file in the package using autopep8, inspected the output of pep8 to drill-down and consider any compliance issues found which may change the meaning of the code (and considered those individually).

I haven't included a unittest for PEP compliance using pep8.

For me this passes all the same tests as the master branch.

Since this affects such a large set of the code it may not be reasonable to pull, however it is certainly a proof of concept.

Some lines were changed manually (those which may change the logic).

Have not fixed E501 line too longs, these are the only pep8 failures.

Check current pep8 compliance of all py files in current directory:
for f in *.py; do pep8 $f; done

Run autopep8 on py files in current directory:
for f in *.py; do autopep8 -i $f; done
66fc98f

Arising from correcting PEP8 E712, changing == boolean to is boolean.
Possible that these are bugs in the tests?
@hayd
Copy link
Contributor Author

hayd commented Jan 3, 2013

To give some idea of the improvements from this, you could run (in pandas/pandas; apologies for poor shell-foo):

pep8 --statistics --filename *.py, */*.py

Comparing the two branches:

autopep8 branch:
4       E203 whitespace before ':'
3       E251 no spaces around keyword / parameter equals
4       E302 expected 2 blank lines, found 1
230     E501 line too long (93 > 79 characters)
6       E712 comparison to False should be 'if cond is False:' or 'if not cond:'

Note: the 4,3,4 results are all from src/generate_code.py, and see second commit re the 6.

master branch:
1       E101 indentation contains mixed spaces and tabs
4       E111 indentation is not a multiple of four
20      E121 continuation line indentation is not a multiple of four
4       E123 closing bracket does not match indentation of opening bracket's line
55      E125 continuation line does not distinguish itself from next logical line
10      E126 continuation line over-indented for hanging indent
106     E127 continuation line over-indented for visual indent
102     E128 continuation line under-indented for visual indent
142     E201 whitespace after '['
116     E202 whitespace before ')'
680     E203 whitespace before ','
2       E211 whitespace before '('
216     E221 multiple spaces before operator
4       E222 multiple spaces after operator
122     E225 missing whitespace around operator
71      E226 missing optional whitespace around operator
1526    E231 missing whitespace after ','
116     E241 multiple spaces after ','
476     E251 no spaces around keyword / parameter equals
61      E261 at least two spaces before inline comment
8       E262 inline comment should start with '# '
3       E271 multiple spaces after keyword
3       E272 multiple spaces before keyword
39      E301 expected 1 blank line, found 0
244     E302 expected 2 blank lines, found 1
69      E303 too many blank lines (3)
1       E401 multiple imports on one line
358     E501 line too long (93 > 79 characters)
3       E502 the backslash is redundant between brackets
32      E701 multiple statements on one line (colon)
3       E702 multiple statements on one line (semicolon)
6       E711 comparison to None should be 'if cond is None:'
14      E712 comparison to True should be 'if cond is True:' or 'if cond:'
1       W191 indentation contains tabs
24      W291 trailing whitespace
7       W293 blank line contains whitespace
7       W391 blank line at end of file
2       W601 .has_key() is deprecated, use 'in'
4       W602 deprecated form of raising exception

Of course, the health warning being that pep8 may not catch all PEP8 compliance issues.

@wesm
Copy link
Member

wesm commented Jan 5, 2013

Thanks for doing this. I guess I should just merge this before there are too many conflicts. The main pep8 thing I have trouble with is 2 blank lines between top level function/class defs. harumph

wesm added a commit that referenced this pull request Jan 5, 2013
@wesm wesm merged commit 5f4ae2a into pandas-dev:master Jan 5, 2013
jreback added a commit to jreback/pandas that referenced this pull request Jan 5, 2013
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.

2 participants