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

STY: Normalize to blue and isort #1124

Merged
merged 12 commits into from
Jan 1, 2023
Merged

Conversation

effigies
Copy link
Member

Looking at #1114, I think we're past the days of asking people to follow style guides. Code formatters have gotten a lot better in the last decade, and it makes more sense to just give people the configuration to auto-format.

Here I'm proposing we use blue, which is like black but doesn't insist on double-quotes everywhere.

I'm also suggesting isort just because I've seen a number of PRs where people's editors auto-sort imports for them, so let's just tell their editors what to do.

The style config becomes:

[flake8]
max-line-length = 99
extend-ignore = E203,E266,E402,E731
exclude =
    *test*
    *sphinx*
    nibabel/externals/*
    */__init__.py

[blue]
line_length = 99
extend-exclude = _version.py

[isort]
extend_skip = _version.py
profile = black
line_length = 99

There are some things I want to revert and protect from re-formatting, most notably the NIfTI intent recoder. But on the whole I find very little objectionable and some things look noticeably better. Any objections / other things to revert and protect?

@codecov
Copy link

codecov bot commented Jul 23, 2022

Codecov Report

Base: 92.38% // Head: 92.38% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (69785cd) compared to base (0a6e73e).
Patch coverage: 91.72% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1124   +/-   ##
=======================================
  Coverage   92.38%   92.38%           
=======================================
  Files          98       98           
  Lines       12264    12257    -7     
  Branches     2520     2520           
=======================================
- Hits        11330    11324    -6     
+ Misses        613      612    -1     
  Partials      321      321           
Impacted Files Coverage Δ
nibabel/environment.py 95.00% <ø> (ø)
nibabel/imagestats.py 83.33% <0.00%> (ø)
nibabel/nicom/structreader.py 100.00% <ø> (ø)
nibabel/nicom/utils.py 100.00% <ø> (ø)
nibabel/onetime.py 90.47% <ø> (ø)
nibabel/pkg_info.py 73.91% <ø> (ø)
nibabel/streamlines/tck.py 99.48% <ø> (-0.01%) ⬇️
nibabel/streamlines/tractogram.py 99.68% <ø> (ø)
nibabel/streamlines/tractogram_file.py 100.00% <ø> (ø)
nibabel/streamlines/trk.py 94.00% <ø> (-0.02%) ⬇️
... and 96 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@effigies effigies force-pushed the sty/normalize branch 3 times, most recently from 13d8a15 to 06aa591 Compare July 27, 2022 03:17
@effigies effigies changed the base branch from master to maint/4.0.x July 27, 2022 11:37
@effigies
Copy link
Member Author

In the absence of feedback, I plan to push on this as time allows and merge when satisfied.

@effigies effigies changed the base branch from maint/4.0.x to master September 11, 2022 18:07
@effigies effigies force-pushed the sty/normalize branch 4 times, most recently from 3e22a51 to 2eceee6 Compare September 11, 2022 20:56
@ZviBaratz
Copy link
Contributor

How do you feel about specifying:

[flake8]
...
per-file-ignores =
    */__init__.py: F401

for init files? Or are there other codes we should be ignoring?

Otherwise, I think it would be great to move forward with this. We can always revert changes in particular files or sections if we find it less readable, and hopefully at some point we will be able to update blue with your PR having been merged. LMK if there's anything I can do to help with this.

effigies and others added 4 commits December 30, 2022 09:05
Run with a custom patch to avoid realigning inline comments:

pipx run --spec git+https://github.com/effigies/blue.git@fix/hanging-comments blue nibabel

[git-blame-ignore-rev]
[git-blame-ignore-rev]
@effigies effigies force-pushed the sty/normalize branch 5 times, most recently from bd4d8fc to f1a85f8 Compare January 1, 2023 00:45
effigies and others added 3 commits December 31, 2022 19:55
Add fmt off/on guards for tabular comments

[git-blame-ignore-rev]
Mostly motivated by excessive use of arguments to super().
Also caught a number of `np.array(X).astype(Y)` to convert to
`np.array(X, Y)`.

[git-blame-ignore-rev]
@effigies
Copy link
Member Author

effigies commented Jan 1, 2023

Let's break all the PRs...

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.

2 participants