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

Coding-sytle: PEP-8 #67

Open
GoogleCodeExporter opened this issue Apr 18, 2015 · 2 comments
Open

Coding-sytle: PEP-8 #67

GoogleCodeExporter opened this issue Apr 18, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Today txt2tags code styling is a mess. Well aligned code is something your 
learn to love one day or another. Mine came later :)

Coding style is a matter of taste, and how I don't want to impose my own taste 
anymore, we need to follow a standard. And PEP-8 is the standard for Python 
code.

http://www.python.org/dev/peps/pep-0008/

I will gradually change the txt2tags code aiming to be closer to PEP-8. Maybe 
being 100% compliant is not needed. But any movement in that direction is a 
win, so I'll start it.

My mais goal for now is simple:

- Use 4 spaces instead TABs for indentation
- One command per line
- One import per line
- Correct spacing between operators (like a = 1)
- Use 'single quotes' for string literals, and """triple double quotes""" for 
docstrings

This will bring absolutely no changes to the code logic or commands, they're 
just visual. But it may affect patches. I guess the most drastic ones will be 
ready in a few hours.

I'll update this issue with news.


Original issue reported on code.google.com by aureliojargas@gmail.com on 12 Nov 2010 at 8:59

@GoogleCodeExporter
Copy link
Author

Okay, items 1, 2 and 3 from the previous list are done.
The commits were from r459-467 (except r462).
I won't change anything in the next 4 or 5 days.
The code is safe to play with again :)

Original comment by aureliojargas@gmail.com on 12 Nov 2010 at 11:29

@GoogleCodeExporter
Copy link
Author

After many commits (search for PEP-8 in log messages), the code now is closer 
to PEP-8 compliance.

There are only 3 errors (with multiple instances) pointed by the pep8.py script 
(http://pypi.python.org/pypi/pep8)

$ pep8 txt2tags 
txt2tags:88:11: E221 multiple spaces before operator
txt2tags:151:80: E501 line too long (142 characters)
txt2tags:244:11: E203 whitespace before ':'
$

This shows only the first line where the error appeared. For a detailed total 
count of each error, one must use --statistics:

$ pep8 --statistics txt2tags 
txt2tags:88:11: E221 multiple spaces before operator
txt2tags:151:80: E501 line too long (142 characters)
txt2tags:244:11: E203 whitespace before ':'
29      E203 whitespace before ':'
132     E221 multiple spaces before operator
149     E501 line too long (142 characters)
$

Fixing these, for now, is not really needed. E203 and E221 are visual 
alignments for dictionary keys and variable setting. Fixing this will break the 
following PEP-8 rule:

(1) When applying the rule would make the code less readable, even for
        someone who is used to reading code that follows the rules.

E501 is about long lines, I'll let it untouched for now. I'm still not sure 
breaking long lines with bring us any benefit.

Please, when writing new code, try to maintain PEP-8 compliance.

Run dist/check-code.sh before a commit (now checking PEP-8 too).


Original comment by aureliojargas@gmail.com on 23 Nov 2010 at 10:59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant