Skip to content

DOC: Command to run flake8 on diff? #16755

Closed

Description

@johannfaouzi

Describe the issue linked to the documentation

In the Contributing code section of the Contributing page, it is stated that:

  1. Make sure that your PR does not add PEP8 violations. On a Unix-like system, you can run make flake8-diff. flake8 path_to_file, would work for any system, but please avoid reformatting parts of the file that your pull request doesn’t change, as it distracts from code review.

I've never been able to run the make flake8-diff command on MacOS. Does it require to install the flake8-diff Python package? The documentation of flake8 states that one can use the following command:

$ git diff -u | flake8 --diff

which works for me.

So I'm maybe asking a dumb question but what are the core devs using currently?

Activity

  1. rth commented on Mar 24, 2020

    @rth
    Member

    I've never been able to run the make flake8-diff command on MacOS. Does it require to install the flake8-diff Python package?

    No it shouldn't. It calls scikit-learn/build_tools/circle/linting.sh which does a number of things to ensure the diff is taken against upstream/master. I agree that recommending,

    git diff upstream/master -u -- "*.py" | flake8 --diff
    

    as pandas does is likely preferable and is cross-plaftorm unlike our script. Although it assumes that contributors have registered the upstream remote. One solution is also to recommend that when cloning same as done in pandas guide.

    +1 to change the docs.

  2. johannfaouzi commented on Mar 24, 2020

    @johannfaouzi
    ContributorAuthor

    Registering the upstream remote is mentioned above:

    1. Add the upstream remote. This saves a reference to the main scikit-learn repository, which you can use to keep your repository synchronized with the latest changes:
      $ git remote add upstream https://github.com/scikit-learn/scikit-learn.git

    And it's an important step if you want to open more than one PR (even for a single PR to solve eventual merge conflicts if the PR takes a while?).

    Waiting for another point of view and opening a PR if there is an agreement :)

  3. adrinjalali commented on Mar 24, 2020

    @adrinjalali
    Member

    yeah we do have it in the docs, but not maybe in the most clear way. Open to suggestions.

    @rth we should also probably only run the "check unused improts" only on the changed files? Now the linting.sh takes quite a while to finish.

  4. rth commented on Mar 24, 2020

    @rth
    Member

    we should also probably only run the "check unused improts" only on the changed files? Now the linting.sh takes quite a while to finish.

    Running it on the diff wouldn't work, because some imports not touched by the diff get unused as a result of the diff. There is also mypy which would add 30s or so https://github.com/scikit-learn/scikit-learn/ . There are likely workarounds to make that CI faster.

  5. rth commented on Mar 24, 2020

    @rth
    Member

    @johannfaouzi feel free to open a PR to improve it.

  6. adrinjalali commented on Mar 24, 2020

    @adrinjalali
    Member

    then I guess I wouldn't even mind having the git diff upstream/master -u -- "*.py" | flake8 --diff in the makefile somewhere.

  7. rth commented on Mar 24, 2020

    @rth
    Member

    Note that makefile is not cross-plaform, so we shouldn't recommend using makefile in the contribution docs IMO. A lot of potential contributors are on windows.

  8. adrinjalali commented on Mar 24, 2020

    @adrinjalali
    Member

    I agree we shouldn't recommend using it for windows users, but it doesn't mean we shouldn't have it for our own sake. We could have it but not recommend it. Although I kinda find it somewhat deeply problematic or ironic that for a lot of our contributing guides it's not what we actually do. I guess we don't have the bandwidth to do it, but it'd be nice to have a contributing guide for everybody, and one for people with a POSIX system.

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