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

Make PEP-8 compatible #98

Open
organisciak opened this issue Apr 11, 2016 · 4 comments
Open

Make PEP-8 compatible #98

organisciak opened this issue Apr 11, 2016 · 4 comments
Assignees

Comments

@organisciak
Copy link
Member

Linting is useful in finding bugs, so I'm hoping to standardize Bookworm style to PEP-8 so that more serious errors stand out. Normally I would do this without an issue, but I want to make sure it's clear what is happening, and need an excuse to just pull the band-aid on full scripts rather than fix lines here or there.

I use flake8 integrated in vim through syntastic, but that's as good as any other linter. Flake8 also works as a command line tool; it currently shows 4470 warnings or errors. It's mostly things like spacing issues, but also useful notes unused imports and variables.

@organisciak organisciak self-assigned this Apr 11, 2016
@organisciak
Copy link
Member Author

Hmm, tackled two files and got 160 errors down. This may take a while ⏳. Looks like I was counting build folder files with the initial alert estimate, so really there's 2132 left.

@bmschmidt
Copy link
Member

Great. You'll see that I only started following the style guide a year ago or so, so good luck!

I don't think you're intending to do this, but since it technically falls under the scope of this: there's loads of camelCase in function definitions where it should be lower_case_with_underscores. Note that fixing all of these might work internally, but break the public API since it relies occasionally on getattr calls.

@organisciak
Copy link
Member Author

I'll avoid changing variable names, and they're not alerted by my style checker anyway. I'm also being careful about the ones where I might introduce a bug, like the 'line too long' alerts, so I'm only doing those when I'm able to test the script well.

@organisciak
Copy link
Member Author

Some of the style change would require overly distracting updates, so I'm thinking of adding them to the ignore list for flake8 and focusing on the others for now. Below are counts for the most common errors in BookwormDB, I think at least the first two are worth ignoring for now, and maybe the next three after that. Any that are F-class are the most useful to fix, like unused imports, references to non-existent variables, and unintended redefinitions.

1166    E231 missing whitespace after ','                                    
1112    E501 line too long (96 > 79 characters)                              
371     E225 missing whitespace around operator                              
304     E265 block comment should start with '# '                            
268     W293 blank line contains whitespace                                  
85      E302 expected 2 blank lines, found 1                                 
83      W291 trailing whitespace                                             
75      E251 unexpected spaces around keyword / parameter equals             
69      E303 too many blank lines (2)                                        
57      F841 local variable 'user' is assigned to but never used             
41      E261 at least two spaces before inline comment                       
31      F401 'os' imported but unused
23      E128 continuation line under-indented for visual indent              
22      F821 undefined name 'db'                                             
21      E262 inline comment should start with '# '                           
20      E221 multiple spaces before operator                                 
18      E266 too many leading '#' for block comment                          
17      W391 blank line at end of file                                       
16      E402 module level import not at top of file                          
15      E703 statement ends with a semicolon                                 
12      E711 comparison to None should be 'if cond is None:'                 
10      E222 multiple spaces after operator                                  
10      E203 whitespace before ','                                           
8       F403 'from tokenizer import *' used; unable to detect undefined names
6       E712 comparison to True should be 'if cond is True:' or 'if cond:'   
6       E502 the backslash is redundant between brackets                     
6       E301 expected 1 blank line, found 0                                  
6       E201 whitespace after '('                                            
6       E101 indentation contains mixed spaces and tabs                      
5       W191 indentation contains tabs                                       
5       F811 redefinition of unused 'os' from line 99                        
4       E228 missing whitespace around modulo operator                       
3       E701 multiple statements on one line (colon)                         
3       E127 continuation line over-indented for visual indent               
3       E124 closing bracket does not match visual indentation               
3       E114 indentation is not a multiple of four (comment)                 
2       E713 test for membership should be 'not in'                          
2       E227 missing whitespace around bitwise or shift operator             
2       E116 unexpected indentation (comment)                                
2       E111 indentation is not a multiple of four                           
1       F812 list comprehension redefines 'n' from line 212                  
1       E272 multiple spaces before keyword                                  
1       E211 whitespace before '('       

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

No branches or pull requests

2 participants