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] run isort and flake8 on the whole nilearn code base in CI #3651

Merged
merged 22 commits into from Jun 14, 2023

Conversation

Remi-Gau
Copy link
Collaborator

@Remi-Gau Remi-Gau commented Apr 4, 2023

Relates to #2528

Changes proposed in this pull request:

  • change CI to run isort and flake on the whole nilearn folder
  • simplify isort and flake8 config
  • fix remaining issues

This PR should be green once the following have been merged:

This will then mean that the whole code base is PEP8 compliant and should hopefully stay that way.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2023

👋 @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.

  • PR has an interpretable title.
  • PR links to Github issue with mention Closes #XXXX (see our documentation on PR structure)
  • Code is PEP8-compliant (see our documentation on coding style)
  • Changelog or what's new entry in doc/changes/latest.rst (see our documentation on PR structure)

For new features:

  • There is at least one unit test per new function / class (see our documentation on testing)
  • The new feature is demoed in at least one relevant example.

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

We will review it as quick as possible, feel free to ping us with questions if needed.

@Remi-Gau Remi-Gau added this to In progress in R&R (reformat and refactor) Apr 4, 2023
@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Merging #3651 (bb4a42e) into main (2e9344d) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3651      +/-   ##
==========================================
- Coverage   91.60%   91.60%   -0.01%     
==========================================
  Files         139      139              
  Lines       16594    16593       -1     
  Branches     3244     3244              
==========================================
- Hits        15201    15200       -1     
  Misses       1390     1390              
  Partials        3        3              
Impacted Files Coverage Δ
nilearn/_utils/testing.py 68.68% <ø> (ø)
nilearn/decoding/space_net_solvers.py 100.00% <ø> (ø)
nilearn/glm/contrasts.py 94.28% <ø> (ø)
nilearn/glm/first_level/design_matrix.py 96.63% <ø> (ø)
nilearn/interfaces/bids/glm.py 95.58% <ø> (ø)
...ces/fmriprep/tests/test_load_confounds_strategy.py 100.00% <ø> (ø)
...rfaces/fmriprep/tests/test_load_confounds_utils.py 100.00% <ø> (ø)
nilearn/interfaces/fmriprep/tests/utils.py 100.00% <ø> (ø)
nilearn/maskers/multi_nifti_masker.py 97.72% <ø> (ø)
nilearn/maskers/nifti_labels_masker.py 93.64% <ø> (ø)
... and 49 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Remi-Gau Remi-Gau marked this pull request as ready for review April 28, 2023 20:01
@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented Apr 28, 2023

  • fix any left over flake8 and isort issues

Once that is done, nilearn should be mostly PEP8 compliant and stay that way.

@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented May 1, 2023

  • add changelog entry to point to all the PRs that have not yet been referenced and concern PEP8 / isort compliance
  • update gitblame ignore

will address those in a separate PR

@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented May 1, 2023

It seems I had slightly misconfigured isort so that it was not always runnning on the whole codebase: started fixing it here which results in a lot of very minor changes in many files.

I also need to finish running it on all the examples: will do this in a subsquent PR as this one is big enough as it is.

@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented May 1, 2023

Getting some install errors for some ci that are unrelated to this PR.
Will try to tackle in a separate PR.

Copy link
Member

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

LGTM otherwise. Thx !

@@ -24,12 +24,12 @@
import numpy as np
from matplotlib import gridspec as mgs
from nibabel.spatialimages import SpatialImage
from nilearn._utils import _compare_version
Copy link
Member

Choose a reason for hiding this comment

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

This is no longer needed ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

flake8 was flagging them as unnecessary because unused so I removed them thinking "for sure this will break something and this will require a 'noqa' to pacify flake8"

so I am a bit puzzled nothing broke

will try to track down when they became unneeded.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Remi-Gau Remi-Gau removed this from In progress in R&R (reformat and refactor) Jun 13, 2023
Copy link
Member

@bthirion bthirion left a comment

Choose a reason for hiding this comment

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

LGTM, thx.

pyproject.toml Outdated
@@ -62,6 +62,7 @@ doc = [
"flake8-docstrings",
"black",
"furo",
"isort",
Copy link
Member

Choose a reason for hiding this comment

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

It looks like flake8 didn't catch the correct indentation on this 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wait... Does flake8 cover toml files as well?
If not I can at least add a pre-commit hook to help "enforce" some formatting of such support / config files (yaml, json, toml).
There are a couple of options available.
https://pre-commit.com/hooks.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

turned out this was a double space instead of a tab...

@Remi-Gau Remi-Gau requested a review from ymzayek June 14, 2023 07:42
Copy link
Member

@ymzayek ymzayek left a comment

Choose a reason for hiding this comment

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

LGTM thx!

@Remi-Gau
Copy link
Collaborator Author

Thanks for the reviews y'all.
Will wait for CI to finish and merge if all green.
Will add a single entry in the changelog for all the new PRs that relate to flake8 / isort.

@Remi-Gau Remi-Gau merged commit 4493330 into nilearn:main Jun 14, 2023
29 checks passed
@Remi-Gau Remi-Gau deleted the maint-pep8_isort branch June 14, 2023 10:28
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.

None yet

4 participants