-
Notifications
You must be signed in to change notification settings - Fork 44
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
Adopt Black and isort #327
Conversation
There are surprisingly few style issues, which is nice to see! @smoia, do you want to use EDIT: Given that we don't want to let PRs sprawl, I think it would be good to open a separate PR (to be merged before this one) in which |
Thank you @tsalo ! It's great to see we were already close to the style required by black.
I'd open a separate PR. |
Ok, one quick thought about this. This solution obliges the user to run black locally instead. I don't love the idea, mainly because it complicates (a little, but still complicates) the process of contributing to the repos - it might scare contributors away (especially new ones) or force them to adopt black during coding. Can we check if setting up a CI action (actually, adding a job in the autorelease GH action would be better) is feasible? |
I considered using the black GitHub Action in NiMARE, but I was wary to give an Action the ability to directly commit to folks' pull requests. I chose to just use a stricter linter in that situation. It doesn't require contributors to run That said, it's up to you. I can try switching things out with an Action, but I honestly think you'd be the best person to set it up. I don't use Actions much (if at all), and the last time I tried it messed up my local repo. |
I see - and understand the warning you're raising. I don't love to force users to adopt opinionated code formatters (or even worse a very opinionated code style) locally, honestly. However, if @physiopy/all prefer to run black locally before PR, we can do that - let's keep the discussion flowing. |
I'd rather have the linter tell us what to change. I think asking contributors to run black locally is a bit too much. I think we should make our lives easier and not complicate our contributions too much! |
What if we discuss this in the upcoming meeting? |
Where did we land on this? Should I close? |
Sorry @tsalo, I've been pretty busy with the rest of my commitments. I need just a bit more time to work on this! |
Hey @tsalo! After that, we can implement pre-commits to automatically run isort and black on the files. |
I'm happy to give it a try. I'll try to fix up this PR later today. |
Thank you! |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #327 +/- ##
==========================================
+ Coverage 94.25% 94.42% +0.17%
==========================================
Files 8 8
Lines 974 879 -95
==========================================
- Hits 918 830 -88
+ Misses 56 49 -7 |
Let me know when you want me to review to merge! BTW, I'm going to configure Pre Commit on all Physiopy packages, so if you want to go ahead and add it here too, I'm following this configuration with this setup from our repository template |
@smoia I added the pre-commit config, but I've never used pre-commit before. Is adding the config file enough? |
Hey @tsalo! On your side it should be sufficient, although you may want to activate it locally. On my side, I just allowed pre-commit to run on phys2bids. pre-commit.ci run |
And now it's running! |
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.
Hey, I trust you're checking the results of the format.
If I can ask you, there's a couple of things we didn't want to automatically format. There are also a couple of issues with strings and if you could set it up to ignore configuration files, that'd be great!
@@ -11,45 +11,90 @@ | |||
LGR = logging.getLogger(__name__) |
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.
If I remember correctly, we wanted not to auto-format the two aliases dictionaries
Oh, and we're not doing checks on tests, at least for docstrings. |
See the following for more info: https://black.readthedocs.io/en/stable/compatible_configs.html#flake8
for more information, see https://pre-commit.ci
@tsalo I tried to update this PR in order to merge it, but I get an error I can't figure out on the style check. Locally, isort and black skip all files. Remotely, something isn't happy. Do you have ideas on why? |
Ok, problem found. It was "just" a black version issue. |
Closes #324.
Proposed Changes
flake8
dependency toflake8-black
. Callingflake8
in the CI will useflake8-black
automatically.flake8
flags, but which is actually not PEP8 compliant. See here for an explanation.