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

Apply Black 2024 to codebase #5252

Merged
merged 9 commits into from Feb 22, 2024
Merged

Conversation

Alnusjaponica
Copy link
Collaborator

Motivation

Remove version specification on black introduced by #5210

Description of the changes

As all the issues mentioned in this comment resolved by black 24.2.0, I applied the new black formatting style to the codebase.
Please note that 2024 black format for @overload is incompatible with flake8 E704, therefore the error message from flake8 is suppressed.

@@ -102,30 +102,24 @@ def suggest_int(
return self._trial.suggest_int(name, low, high, step=step, log=log)

@overload
def suggest_categorical(self, name: str, choices: Sequence[None]) -> None:
...
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about using pass or raise NotImplemented instead of ...?

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 have no strong opinion on this topic but it is reasonable to ignore E704 in this case as mentioned in psf/black#3887 and PEP8. I think it is possible to put pass since NotImplementedError raises when function with @overload is actually called no matter what we write in the body .

Copy link
Member

Choose a reason for hiding this comment

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

IMO, changing the implementation is out of scope of this PR, since this PR aims just to introduce black 2024.

Copy link

codecov bot commented Feb 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1bcda7a) 89.23% compared to head (c3f9671) 89.43%.
Report is 51 commits behind head on master.

❗ Current head c3f9671 differs from pull request most recent head 510e7f6. Consider uploading reports for the commit 510e7f6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5252      +/-   ##
==========================================
+ Coverage   89.23%   89.43%   +0.19%     
==========================================
  Files         206      206              
  Lines       12944    12914      -30     
==========================================
- Hits        11550    11549       -1     
+ Misses       1394     1365      -29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Alnusjaponica Alnusjaponica marked this pull request as ready for review February 15, 2024 04:24
@HideakiImamura
Copy link
Member

@contramundum53 Could you review this PR?

Copy link
Member

@HideakiImamura HideakiImamura left a comment

Choose a reason for hiding this comment

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

LGTM.

@HideakiImamura HideakiImamura removed their assignment Feb 15, 2024
@HideakiImamura
Copy link
Member

It would be great to add E704 to the ignore section of setup.cfg.

@Alnusjaponica
Copy link
Collaborator Author

@HideakiImamura
Sure, shall I propagate the same changes to optuna-examples and optuna-integration?

Copy link
Collaborator

@nabenabe0928 nabenabe0928 left a comment

Choose a reason for hiding this comment

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

I will approve this PR after #5252 (comment) is addressed.

@contramundum53
Copy link
Member

@Alnusjaponica Could you resolve the conflict? I think lightgbm tuner has been moved to optuna_integration.

Copy link
Collaborator

@nabenabe0928 nabenabe0928 left a comment

Choose a reason for hiding this comment

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

Now, we can remove NOQA from:

  • optuna/trial/_base.py
  • optun/trial/_fixed.py
  • optuna/trial/_frozen.py
  • optuna/trial_trial.py

Btw, were the merged changes also formatted already?

@Alnusjaponica
Copy link
Collaborator Author

@nabenabe0928
Thanks for your remark. I removed newly added #noqas

Btw, were the merged changes also formatted already?

It should be formatted since Check have passed.

Copy link
Collaborator

@nabenabe0928 nabenabe0928 left a comment

Choose a reason for hiding this comment

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

Thank you for the changes, LGTM!

@nabenabe0928 nabenabe0928 merged commit 7192d0f into optuna:master Feb 22, 2024
26 checks passed
@Alnusjaponica Alnusjaponica deleted the update-black branch February 22, 2024 04:24
@nabenabe0928 nabenabe0928 added this to the v3.6.0 milestone Feb 23, 2024
@nabenabe0928 nabenabe0928 added the code-fix Change that does not change the behavior, such as code refactoring. label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-fix Change that does not change the behavior, such as code refactoring.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants