Skip to content
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

MAINT Update pre-commit setup for black #20292

Merged
merged 3 commits into from
Jun 18, 2021
Merged

Conversation

rth
Copy link
Member

@rth rth commented Jun 17, 2021

Update pre-commit setup for black

Also run all flake8 checks enabled in config using pre-commit

Unless you had it in some other PR @thomasjpfan ?

@rth rth changed the title Update pre-commit setup for black MAINT Update pre-commit setup for black Jun 17, 2021
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

hooks:
- id: flake8
types: [file, python]
# only check for unused imports for now, as long as
# the code is not fully PEP8 compatible
args: [--select=F401]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a problem when working on the examples which allow delayed import statements when using the notebook style code layout and the non-blackified files such as benchmark scripts, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, because we don't want to use # noqa in examples? I think we should come up with a config that would make flake8 . just work; related #20296 .

But since this requires more discussion, let me revert the flake8 change, here having black setup would be already good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then with per-file-ignores it should be fine.

Copy link
Member

@ogrisel ogrisel Jun 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approved the PR. Feel free to merge it assuming you tested it and it does not yield spurious rejections when working on the examples.

@rth
Copy link
Member Author

rth commented Jun 17, 2021

Feel free to merge it assuming you tested it and it does not yield spurious rejections when working on the examples.

It runs flake8 on examples, and overall we currently have around 50 flake8 errors there #20296 . However it only runs on the modified files on commit. So it will only tell you to fix the included flake8 errors, if you edit one of those examples.

@thomasjpfan
Copy link
Member

I opened #20298 to make sure that flake8 . works on main.

@rth
Copy link
Member Author

rth commented Jun 18, 2021

Thanks @thomasjpfan ! Merging this then as it would be quite useful to have the black pre-commit on PRs currently.

@rth rth merged commit bf0da87 into scikit-learn:main Jun 18, 2021
@rth rth deleted the black-pre-commit branch June 18, 2021 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants