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

[FMT] apply toml formatting hook on pyproject.toml #3872

Merged
merged 2 commits into from Aug 3, 2023

Conversation

Remi-Gau
Copy link
Collaborator

@Remi-Gau Remi-Gau commented Aug 1, 2023

Closes #3870

Changes proposed in this pull request:

  • adds a pre-commit hook for toml formatting to the pre-commit config
  • apply the hook

Advantages

  • toml is formatted

Drawback

  • only if people install the hook (could be solved by adding something in CI)

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 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
Copy link
Collaborator Author

Remi-Gau commented Aug 1, 2023

The default config of this formater sorts the content of the toml alphabetically which has its pros and cons

@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented Aug 1, 2023

Can check if there is more config option to avoid this reformatting

@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Merging #3872 (a61721e) into main (a95149b) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #3872   +/-   ##
=======================================
  Coverage   91.60%   91.60%           
=======================================
  Files         134      134           
  Lines       15705    15705           
  Branches     3270     3270           
=======================================
  Hits        14386    14386           
  Misses        770      770           
  Partials      549      549           
Flag Coverage Δ
macos-latest_3.10 91.52% <ø> (ø)
macos-latest_3.11 91.52% <ø> (ø)
macos-latest_3.8 91.48% <ø> (ø)
macos-latest_3.9 91.48% <ø> (ø)
ubuntu-latest_3.10 91.52% <ø> (ø)
ubuntu-latest_3.11 91.52% <ø> (ø)
ubuntu-latest_3.8 91.48% <ø> (ø)
ubuntu-latest_3.9 91.48% <ø> (ø)
windows-latest_3.10 91.46% <ø> (ø)
windows-latest_3.11 91.46% <ø> (ø)
windows-latest_3.8 91.43% <ø> (ø)
windows-latest_3.9 91.43% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

rev: v2.10.0
hooks:
- id: pretty-format-toml
args: [--autofix, --indent, '2']
Copy link
Member

Choose a reason for hiding this comment

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

Any particular reason why 2 spaces instead of 4 ? I can't find a good, accepted style guide for TOML, so I'd think this is just developer preference.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I honestly went with what was in the read of the pre-commit hook repo? You want 4, let's do 4.you want 8, let's do 8. You want 16... Get me a larger screen.

Copy link
Member

Choose a reason for hiding this comment

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

😂 Just wanted to confirm that there wasn't a style guide I was missing ! I'm fine with 2 or 4.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

given that our code uses 4, let's go with 4 to avoid the mental gymnastic of 4 for python, 2 for toml (my brain is too old and unflexible for those exercises)

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 so far.

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.

I do prefer the original order for some tables like project but I'm not too bothered by it. LGTM otherwise, thx!

@Remi-Gau Remi-Gau marked this pull request as ready for review August 3, 2023 09:15
@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented Aug 3, 2023

OK let's get this in then

@Remi-Gau Remi-Gau merged commit 5734dba into nilearn:main Aug 3, 2023
29 checks passed
@Remi-Gau Remi-Gau deleted the toml_format branch August 3, 2023 09:15
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.

[MAINT] Standardize tabs and spaces in pyproject.toml
4 participants