Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: Command to run flake8 on diff? #16755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
johannfaouzi opened this issue Mar 24, 2020 · 8 comments · Fixed by #16758
Closed

DOC: Command to run flake8 on diff? #16755

johannfaouzi opened this issue Mar 24, 2020 · 8 comments · Fixed by #16758

Comments

@johannfaouzi
Copy link
Contributor

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?

@rth
Copy link
Member

rth commented Mar 24, 2020

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.

@johannfaouzi
Copy link
Contributor Author

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 :)

@adrinjalali
Copy link
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.

@rth
Copy link
Member

rth commented Mar 24, 2020

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.

@rth
Copy link
Member

rth commented Mar 24, 2020

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

@adrinjalali
Copy link
Member

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

@rth
Copy link
Member

rth commented Mar 24, 2020

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.

@adrinjalali
Copy link
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants