Skip to content

Refine PEP8 standards for TravisCI and git pre-commit hook #883

Closed

Description

@peterjc

Issue #840 (via pull request #877) added pep8 checks to TravisCI, issue #493 describes a git pre-commit hook to enforce pep8 style guidelines.

Currently the TravisCI setup applies different pep8 strictness to the top level folders (out of practicality), but medium term we should try to agree on and fix remaining issues in order to have a single strictly enforced set of pep8 checks. I would suggest having the git pre-commit hook being even stricter (but optionally enforced).

As suggested by @bow on #840, we could then record these settings in a setup.cfg or .pep8 file which would be used by most of the PEP8 testing tools (including local testing and some editors).

This information also needs to be added to our contribution guidelines, currently at http://biopython.org/wiki/Contributing

Activity

  1. bow commented on Mar 6, 2017

    @bow
    Member

    Hi @peterjc,

    This isn't exactly the refined PEP8 standard we are aiming for, but what do you think about moving the per-directory style settings out of the .travis-tox.ini file and into separate config in the respective directories (i.e. something like this)?

    Would this have any downside compared to the current setup that I may be missing? The upside is that now some editors can read and apply the style checks on the fly already :).

  2. peterjc commented on Mar 7, 2017

    @peterjc
    MemberAuthor

    Good plan. 👍

    Since I transitioned from the command line tool pep8 to flake8 that makes a lot of sense. When we used the command line tool pep8 (now renamed pycodestyle), per-folder settings did not seem to be easily possible with hidden files https://pycodestyle.readthedocs.io/en/latest/intro.html#configuration

    If we need to use per-folder . pydocstyle files, according to http://www.pydocstyle.org/en/latest/snippets/config.html that would work too.

    Do you want to apply that change directly and/or make a pull request?

  3. bow commented on Mar 7, 2017

    @bow
    Member

    I can apply this directly sometime later today, if that's ok.

    On second look, what do you think about using setup.cfg instead of .pycodestyle in the root folder? The goal is then to gradually remove the .flake8 files in the subdirectories to have just a single [flake8] entry in the root setup.cfg (in other words, to have a single style setting for the entire Biopython).

  4. peterjc commented on Mar 7, 2017

    @peterjc
    MemberAuthor

    I certainly would hope we can get to a single flake8 configuration for the whole of Biopython.

    I'm a little less settled on yet another non-hidden file in the project root, but that does make sense as a longer term goal covering all the style settings.

  5. bow commented on Mar 7, 2017

    @bow
    Member

    I'm a little less settled on yet another non-hidden file in the project root, but that does make sense as a longer term goal covering all the style settings.

    Ok then. I'll apply the changes here as-is to master soon.

  6. bow commented on Mar 7, 2017

    @bow
    Member

    Done in 3027734 ~

  7. souravsingh commented on Apr 22, 2017

    @souravsingh
    Contributor

    @peterjc We can make use of Coala for the pre-commit checks in docstrings and Lint errors. It has integration with Travis, but I am not sure if it works with Tox.

  8. peterjc commented on Apr 22, 2017

    @peterjc
    MemberAuthor

    @souravsingh if Coala has an easy to install git pre-commit hook, which we can configure to match our current settings (or it reads the .flake8 and .pydocstyle files etc), that might be interesting. Could you look into this please?

  9. souravsingh commented on Apr 22, 2017

    @souravsingh
    Contributor

    Coala doesn't read the .flake8 or .pydocstyle file, but it makes use of a .coafile config file to set parameters for the various bears( PEP8Bear, PyDocStyleBear etc.)

  10. peterjc commented on Apr 22, 2017

    @peterjc
    MemberAuthor

    So it is simple to match what we're doing right now (i.e. copy the current ignore lists), and use coala for (1) the TravisCI style checks and (2) a git pre-commit check?

  11. souravsingh commented on Apr 22, 2017

    @souravsingh
    Contributor

    Yes, As for a git pre-commit check, I think something like Gitmate could be handy.

  12. peterjc commented on May 1, 2017

    @peterjc
    MemberAuthor

    As part of #1199 I've started commenting the .flake8 configuration so we can explain why we might be ignoring specific checks.

  13. peterjc commented on May 23, 2019

    @peterjc
    MemberAuthor

    I think that as of PR #2074 with a single top level .flake8 file, we can mark this issue as closed.

    The ignore list in the file is documented with error codes we intentionally ignore versus those we would like to enforce in future.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions