[Biopython-dev] git pre-commit hook for PEP8 style checking

Peter Cock p.j.a.cock at googlemail.com
Mon Oct 20 11:31:45 UTC 2014


Thanks Christian,

I'm giving that a try on my mac - note you don't need pip to install pep8,

$ curl -O https://pypi.python.org/packages/source/p/pep8/pep8-1.5.7.tar.gz
$ tar -zxvf pep8-1.5.7.tar.gz
$ md5 pep8-1.5.7.tar.gz
MD5 (pep8-1.5.7.tar.gz) = f6adbdd69365ecca20513c709f9b7c93
$ cd pep8-1.5.7
$ sudo python setup.py install
$ which pep8
/usr/local/bin/pep8
$ head -n 1 /usr/local/bin/pep8
#!/usr/bin/python
$ pep8 --version
1.5.7

Note we want pep8 installed as a binary on the path (which is itself
a Python script). This is then called by git via the pre-commit hook -
the hook from Christian is another Python script (using the default
system python) which calls the pep8 binary.

I would hope this is doable on Windows too...

Peter

On Mon, Oct 20, 2014 at 11:32 AM, Christian Brueffer
<christian at brueffer.de> wrote:
> Hi everyone,
>
> TL;DR: lots of style problems in biopython code, please consider using the
> git pre-commit hook at https://github.com/cbrueffer/pep8-git-hook (or check
> your files manually with the pep8 utility).
>
>
> Long version:
>
> Since the last round of PEP8 fixes to the biopython repo almost two years
> ago, many classes of inconsistencies have unfortunately slowly crept back
> in.
>
> One way to check the code you're committing is via a git pre-commit hook,
> which tells you which kinds of problems your submissions contain.
>
> Such a commit hook can be found here:
>
> https://github.com/cbrueffer/pep8-git-hook
>
> Installation is easy, simply copy the pre-commit file from the above
> repository into the following directory in your biopython checkout:
> .git/hooks
> You also need the pep8 utility (pip install pep8).
>
> A list of problem classes pep8 reports can be found here:
> http://pep8.readthedocs.org/en/latest/intro.html#error-codes
>
> By default the hook checks for all of these problems, except the following
> ones: E121-E129, E131, and E501 (indentation and long lines).
>
> The way it works is, the hook stops your commit and tells you which issues
> your code contains.  The hook won't bother you if the files in the commit
> contain no issues, or you commit with --no-verify (e.g., git commit -a
> --no-verify).  The latter is especially for situations where your code is
> fine, but files contain pre-existing issues.
>
> Please test this and let me know what you think, whether the list of issues
> should be adapted etc.  Continuous checking would improve our code
> consistency a lot in the long run.
>
> Cheers,
>
> Chris
> _______________________________________________
> Biopython-dev mailing list
> Biopython-dev at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython-dev


More information about the Biopython-dev mailing list