[Biopython-dev] Fwd: git pre-commit hook for PEP8 style checking
Peter Cock
p.j.a.cock at googlemail.com
Mon Oct 20 16:19:10 UTC 2014
Hi Travis,
I'd keep docstring changes (and reStructuredText conventions) as a
separate discussion to PEP8 changes to the code or doctests.
To be clear, a blanket enforcement of all of PEP8 is not possible due
to legacy code that we can't change without breaking existing usage
(e.g. module names).
As you will have noticed on GitHub, Christian has been doing batches
of fixes for particular issues - each of which is quite simple to review,
but still needs care as occasionally seemingly innocent changes can
break code. I believe he has focused on the less contentious issues.
Note Christian's proposed Git Hook only runs a subset of the possible
PEP8 checks - are you using the same of the full set?
Peter
On Mon, Oct 20, 2014 at 4:50 PM, Travis Wrightsman <twrig002 at ucr.edu> wrote:
> Forgot reply to all.
> Just ran pep8 on the latest commit and got almost 30,000 errors. Looks like
> we have our work cut out for us. Should we discuss formatting choices for
> docstrings before starting on the PEP8 corrections so that both can be
> updated at the same time as we go through the code? Or should the tasks be
> separate?
>
> -Travis
>
> On Mon, Oct 20, 2014 at 8:02 AM, Christian Brueffer <christian at brueffer.de>
> wrote:
>>
>> Hi Peter,
>>
>> indeed, there is more than one way to install pep8. Windows feedback
>> would be great, I don't have a test machine for that.
>>
>> One nice feature of pep8 is getting overall statistics with pep8
>> --statistics -qq from the top level repository directory. Maybe it would be
>> interesting to set up a job to automatically send these statistics to this
>> list in certain intervals (i.e., once a month).
>>
>> Chris
>>
>>
>>
>> On 2014-10-20 13:31, Peter Cock wrote:
>>>
>>> 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
>>
>> _______________________________________________
>> Biopython-dev mailing list
>> Biopython-dev at mailman.open-bio.org
>> http://mailman.open-bio.org/mailman/listinfo/biopython-dev
>
>
>
>
> _______________________________________________
> 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