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] add workflow to check for f strings #3759

Merged
merged 10 commits into from Jun 20, 2023
Merged

Conversation

Remi-Gau
Copy link
Collaborator

Closes #2528
Relates to https://github.com/orgs/nilearn/projects/2/views/1?pane=issue&itemId=30677086

Changes proposed in this pull request:

  • add workflow to run flynt on main and PRs
  • add flynt config to pyproject.toml
  • run flynt

@github-actions
Copy link
Contributor

github-actions bot commented Jun 15, 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.

@codecov
Copy link

codecov bot commented Jun 15, 2023

Codecov Report

Merging #3759 (15a7633) into main (bb59d69) will not change coverage.
The diff coverage is 0.00%.

@@           Coverage Diff           @@
##             main    #3759   +/-   ##
=======================================
  Coverage   91.65%   91.65%           
=======================================
  Files         139      139           
  Lines       16554    16554           
  Branches     3230     3230           
=======================================
  Hits        15172    15172           
  Misses       1379     1379           
  Partials        3        3           
Impacted Files Coverage Δ
nilearn/_utils/data_gen.py 98.43% <ø> (ø)
nilearn/_utils/docs.py 93.65% <0.00%> (ø)

📣 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 June 15, 2023 12:48
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.

So the github workflow will fail if any code is added with % or .format() formatting ?

.github/workflows/f_strings.yml Outdated Show resolved Hide resolved
Co-authored-by: Yasmin <63292494+ymzayek@users.noreply.github.com>
@Remi-Gau
Copy link
Collaborator Author

So the github workflow will fail if any code is added with % or .format() formatting ?

only for the simplest usage of % and format

in terms of complexity flynt acts like a high-pass filter for string formatting

it has an "aggressive" option to force reformating but the doc itself that those reformating may result in behavior change

does that make sense?

@Remi-Gau
Copy link
Collaborator Author

oh and it is already one the pre-commit hook that is run, this would just provide an official check in CI

@tsalo
Copy link
Member

tsalo commented Jun 15, 2023

@Remi-Gau have you looked at flake8-use-fstring? I don't know if it's better or worse than flynt, but you'd be able to include it in the flake8 workflow that already exists.

@Remi-Gau
Copy link
Collaborator Author

Was not aware of this one. Will investigate.

@Remi-Gau
Copy link
Collaborator Author

@Remi-Gau have you looked at flake8-use-fstring? I don't know if it's better or worse than flynt, but you'd be able to include it in the flake8 workflow that already exists.

OK as far I can tell the 2 are not completely mutually exclusive. Flynt will actually try to convert % and Format to f strings but can only do the most simple ones because it tries to be conservative.

The flake8 extension will flag % and format and potentially report them as error.

So the 2 could coexist but one will throw more errors than the other when used for Linting purposes.

I would suggest to start with Flynt and and then tackle the remaining non f strings. Then we can switch to flake8 extensions to ensure we stick to f strings from now on.

@tsalo
Copy link
Member

tsalo commented Jun 15, 2023

👍 sounds good to me. Thanks for taking a look at the flake8 extension.

Co-authored-by: bthirion <bertrand.thirion@inria.fr>
@bthirion
Copy link
Member

The PR LGTM, but I think lots of red CI.

@Remi-Gau
Copy link
Collaborator Author

The PR LGTM, but I think lots of red CI.

yeah I will rebase to clean some of that

github-actions bot and others added 4 commits June 19, 2023 21:28
Co-authored-by: Remi-Gau <Remi-Gau@users.noreply.github.com>
* update git-blame-ignore

* update changelog

* fix

* update ignore

* fix regex escape

* flake8

* use list and not set

* simplify rev file

* rm spaces

* pragmatism wins

* rm import

* reset plotting files
…r` message (nilearn#3763)

* Modify ValueError string

* Warning based on sklearn version
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.

Now it mixed several things but LGTM overall.

@Remi-Gau
Copy link
Collaborator Author

yeah some files should not be in that diff: will fix

@Remi-Gau Remi-Gau merged commit 88b4232 into nilearn:main Jun 20, 2023
27 of 30 checks passed
@Remi-Gau Remi-Gau deleted the maint/flynt branch June 20, 2023 03:43
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.

Automate the Formatting stuff
4 participants