-
Notifications
You must be signed in to change notification settings - Fork 576
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
[INFRA] Initial formatting with black and precommit #3484
Conversation
👋 @Remi-Gau Thanks for creating a PR! Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft. Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.
We will review it as quick as possible, feel free to ping us with questions if needed. |
setup.cfg
Outdated
@@ -72,6 +72,7 @@ dev = | |||
# W503: line break before binary operator | |||
# W504: line break after binary operator | |||
ignore=E402, W503, W504, W605 | |||
max-line-length = 91 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could bring this number down but if I do Flake8 would complain for some files in this PR.
Other possibility I could try is setting the config for black for shorter lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I'm just curious about where these numbers come from... Ten we simply need to decide collectively what we think is best for readability.
Actually, I'm a bit surprised to see how these things fluctuate across years ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record there is a quite bit of variability indeed.
Did set things at 90 for now (because 91 is just a weird number).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the flake8 default is 79 and that's what we've been using before our PEP8 CI broke
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't feel strongly about any specific value: will change the value and adapt.
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
|
||
files: "nilearn/decomposition" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding new modules and other files will have to be done by modifying this line.
It should be a valid python regex.
While the code formatting is transitioning it may be good to:
|
Regarding mentions in the changelog, it may make sense to have a single entry once most of the code has been blackified (blacked?) rather than one per PR, no? |
I could not see any code in the reformated files that contained code that had a "table like" layout that would have been mangled by black. Let me know, if you think I overlooked something. |
Codecov Report
@@ Coverage Diff @@
## main #3484 +/- ##
==========================================
+ Coverage 90.94% 90.99% +0.04%
==========================================
Files 133 133
Lines 15335 15343 +8
Branches 3024 3028 +4
==========================================
+ Hits 13947 13961 +14
+ Misses 820 817 -3
+ Partials 568 565 -3
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great ! Thanks for taking care of that @Remi-Gau ! 👍
I went through the changes and they all LGTM.
Concerning the documentation, I also think we should add a few things related to setting up the pre-commit hook, probably here: https://nilearn.github.io/stable/development.html#setting-up-your-environment
Also, we should make sure our coding style guidelines (https://nilearn.github.io/stable/development.html#coding-style) are consistent with the linting we're enforcing.
Concerning the changelog, I also agree it might be cleaner to have only a single entry for the formatting of the whole code base rather than one entry per PR.
That being said, if we keep the one PR per module style, and different contributors end up doing them, I don't think that it would be a huge deal either...
Ok I will update the contributing (but not today). Also I am realizing that unless we use something like pre-commit ci, it may be good to have something in CI that runs black to at least say which files in the PR should be formatted with black. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes so far LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise.
OK I think I am done with this PR. Let me know if I am missing anything or if I should change anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this set up looks great!
Can you also remove the recommendation in step 3 under here: https://nilearn.github.io/stable/development.html#id3 and replace with a code block of syntax to flake8 a file? |
done also added mention of black and pre-commit |
The documentation builder failure is unrelated, see actions/runner-images#7048 For the codecov patch failure, I'm guessing we're gonna see this when reformatting the code base as it will pick up on untested lines that are changed by the reformatting since it runs on the diff. I think we can ignore for these PRs but it could be an idea to start increasing the testing coverage in general for nilearn (in separate PRs based on these reports). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Remi-Gau!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @Remi-Gau !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thx.
.pre-commit-config.yaml
Outdated
- id: trailing-whitespace | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Black had just released a new version, so I should probably bump this before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, you can go ahead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Once this is merged I will open a separate PR with a workflow to check and update the hooks version weekly so we don't have to remember to regularly update this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great thanks!
Ok merging |
Relates to #2528
Changes proposed in this pull request:
nilearn/decomposition
modulenilearn/decomposition
usingpre-commit run -a