[Biopython-dev] Fwd: git pre-commit hook for PEP8 style checking
Peter Cock
p.j.a.cock at googlemail.com
Mon Oct 20 22:29:03 UTC 2014
On Mon, Oct 20, 2014 at 7:32 PM, Christian Brueffer
<christian at brueffer.de> wrote:
> I agree, that's why it's in the ignore_list in the hook :-) The length
> is configurable through "pep8 --max-line-length=n" though, in case we
> agree something should be done about that sometime down the line.
>
> The current ignored codes are these:
>
> E121-E129, E131, and E501 (indentation and long lines)
Sounds sensible :)
P.S. thanks for digging out the line length option to the
pep8 tool.
> Maybe we should also ignore the following for now:
>
> E261 at least two spaces before inline comment
E261 seems a bit unnecessary (I don't find it noticeably clearer
than a single space), but on the other hand it should be very
low risk to apply to existing codebase automatically?
> E225 missing whitespace around operator
> E226 missing whitespace around arithmetic operator
> E227 missing whitespace around bitwise or shift operator
> E228 missing whitespace around modulo operator
>
> Especially whitespace around operators is controversial, I think. I
> like it most of the time, but in some cases (e.g., array slicing,
> complex formulas), I find no whitespace to be more readable.
I agree that whitespace around operators can be controversial,
and the ideal/clearest form will depend on the context - and so
probably not worth including in a Biopython git pre-commit hook?
However, I expected some of those operators are very rare in
Biopython, to the point where i decided to just 'fix' all the bit-shifting
E227 cases which seemed to just be in one file I wrote:
$ pep8 -r --select E227 setup.py Bio BioSQL Tests Doc/examples Scripts
Bio/bgzf.py:303:31: E227 missing whitespace around bitwise or shift operator
Bio/bgzf.py:315:27: E227 missing whitespace around bitwise or shift operator
Bio/bgzf.py:316:42: E227 missing whitespace around bitwise or shift operator
Bio/bgzf.py:600:45: E227 missing whitespace around bitwise or shift operator
Bio/bgzf.py:606:38: E227 missing whitespace around bitwise or shift operator
Bio/bgzf.py:607:54: E227 missing whitespace around bitwise or shift operator
Note that I didn't like the output of autopep8 which seemed to only
add a space on the left (but not the right?!). Very strange:
$ autopep8 --version
autopep8 1.0.4
$ autopep8 --select E227 -i Bio/bgzf.py
So I made the rest of the changes in the bgzf.py commit by hand:
https://github.com/biopython/biopython/commit/9122de8d2550ce26f47ec6ebc6fd0c6a8832dae8
Peter
More information about the Biopython-dev
mailing list