Skip to content

Too strict settings for flake8 in TravisCI build #9121

Closed

Description

@rth

Description

The flake8 Travis CI build currently runs flake8 --ignore=W503 <files> on modified (non example) files. This is much stricter than the defaults which are --ignore=E121,E123,E126,E226,E24,E704,W503,W504 in the latest flake8 verison. This leads to an inefficient contribution workflow (and sometimes non PEP8 compatible style). Also related to @GaelVaroquaux observations about it during the last sprint.

What do you think @lesteve ?

Steps/Code to Reproduce

flake8_example.py

x, y = 2, 3
x = x*2 - 1
hypot2 = x*x + y*y
  1. Run flake8 flake8_example.py => everything looks OK.
  2. Make a PR with this code to scikit-learn. Wait 20min. See the Travis CI flake8 build fail (e.g. in [MRG+1] Add text vectorizers benchmarks #9086).
  3. Rerun flake8 on your machine => still looks OK. Install the same version of flake8 => still no errors
  4. Start reading through scikit-learn/build_tools/travis/flake8_diff.sh
  5. Wonder why it fails, read through related flake8 issues

Expected Results

No errors, since this is valid PEP8 code taken from https://www.python.org/dev/peps/pep-0008/#other-recommendations.

I understand that less strict settings, might mean potentially more comments during PR reviews. At least; when Travis CI fails due to flake8 it should print the settings of flake8 that were used.

Actual Results

Some lost contributors time.

Versions

master scikit-learn branch, flake8 3.3.0

Activity

  1. jnothman commented on Jun 14, 2017

    @jnothman
    Member
  2. lesteve commented on Jun 14, 2017

    @lesteve
    Member

    Looks like an oversight more than anything else and I would be happy to review PRs to make the experience more pleasant for everyone involved.

    A few comments:

    • flake8 2.5.1 is used on the CI because flake 3.3.0 checks non python files in the diff. I seem to remember there was an issue about this but I didn't check recently.
    • you should run bash build_tools/travis/flake8_diff.sh locally (you need to commit first) if you want to run the same command as on Travis (care was taken to make sure that the command could be run locally as well on Travis). Using flake8 2.5.1 is required here too.
  3. lesteve commented on Jun 14, 2017

    @lesteve
    Member

    Happy to remove the --ignore flag.

    I think we want to add the default i.e. --ignore=E121,E123,E126,E226,E24,E704,W503,W504 instead.

    and probably do something similar for the examples.

    BTW out of curiosity, do you have an example of a failing build?

  4. lesteve commented on Jun 14, 2017

    @lesteve
    Member

    BTW out of curiosity, do you have an example of a failing build?

    OK I missed it from your original post, sorry. On #9086 it does not fail locally, no idea why it fails on Travis ...

  5. rth commented on Jun 14, 2017

    @rth
    MemberAuthor

    Thanks for your reponse @jnothman and @lesteve ! Makes sens, flake8 defaults might have also changed in the last few years.

    I think we want to add the default i.e. --ignore=E121,E123,E126,E226,E24,E704,W503,W504 instead.

    Sure, could you just please double check that those are indeed the default? Read it in the flask8 docs, but didn't check the code... Thanks )

    OK I missed it from your original post, sorry. On #9086 it does not fail locally, no idea why it fails on Travis ...

    Yes that was https://travis-ci.org/scikit-learn/scikit-learn/jobs/241700810 , not sure either..

    Made a PR following your suggestions in #9123

  6. lesteve commented on Jun 14, 2017

    @lesteve
    Member

    I think that's the problem is that:

    • In Travis: we run flake8_diff.sh from master which has the --ignore W503 argument
    • Locally we run flake8_diff.sh from the PR branch which does not have the --ignore W503 argument and as such ignore the default stuff.

    😠 this is a bit confusing, I think I should fix that ...

  7. lesteve commented on Jun 14, 2017

    @lesteve
    Member

    😠 this is a bit confusing, I think I should fix that ...

    I don't think there is an easy fix actually without adding too much complexity so I am going to leave it like this and promise to look at this in case a similar problem happens again.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions