[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
GOP-PROP 1: python formatting - probable decision
From: |
Graham Percival |
Subject: |
GOP-PROP 1: python formatting - probable decision |
Date: |
Wed, 15 Jun 2011 00:11:37 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
Unless anybody has a compelling reason against it, this is the
proposal which will be adopted on 22 June 2011:
http://lilypond.org/~graham/gop/gop_1.html
GOP 1 - python formatting
Proposal summary
let’s follow the indentation described in PEP-8.
http://www.python.org/dev/peps/pep-0008/
* use 4 spaces per indentation level
* never mix tabs and spaces (for indentation)
* Code indented with a mixture of tabs and spaces should be
converted to using spaces exclusively
Once this is done, we should add "python -tt" to the build
system to avoid such errors in the future.
There should be absolutely no tab characters for indentation in
any .py file in lilypond git. All such files should be converted
to use spaces only.
Rationale
Mixing indentation styles is not a great idea, and in my
experience of python code documentation and examples online, the
4-space indent rule from PEP-8 is almost universally followed.
Implementation notes
We have very few (or none) patches for python files, so a large
whitespace change should not break any pending patches.
You can see offending files with: (that said, this command may
give false positives; it catches any tab character in a file, not
just tabs used for indentation)
address@hidden:~/src/lilypond$ git grep -l $'\t' --
"*.py"
python/convertrules.py
python/fontextract.py
python/lilylib.py
python/musicxml.py
python/rational.py
scripts/auxiliar/makelsr.py
scripts/build/create-weblinks-itexi.py
scripts/build/website_post.py
scripts/musicxml2ly.py
On the command-line, there’s the expand(1) command. Alternately, a
text editor could be used to replace \t with 8 spaces. I _think_
that all instances of tabs are used to represent 8 spaces (one of
the curses of emacs), but since indentation is so important in
python files, I fear that manual attention to any automatic system
is required.
potentially useful tool:
http://hg.python.org/cpython/file/ba975c7c33d3/Tools/scripts/reindent.py
Cheers,
- Graham
- GOP-PROP 1: python formatting - probable decision,
Graham Percival <=