Skip to content

Replace .format() with f-strings in 002_configurations.py#6506

Merged
c-bata merged 1 commit intooptuna:masterfrom
acabellom:fix-fstring-file
Mar 12, 2026
Merged

Replace .format() with f-strings in 002_configurations.py#6506
c-bata merged 1 commit intooptuna:masterfrom
acabellom:fix-fstring-file

Conversation

@acabellom
Copy link
Copy Markdown
Contributor

Motivation
This PR addresses the issue of replacing the legacy .format() string formatting with modern f-strings (#6305).
Since Optuna no longer supports Python 3.8, the project can adopt f-strings consistently for cleaner and more readable code.

As suggested in the issue, this PR updates the formatting in a single file.

Description of the changes

Replaced the usage of .format() with an f-string in the example code.

Specifically:

"n_units_l{}".format(i)

was replaced with:

f"n_units_l{i}"

No other logic or behavior was modified. The change is purely stylistic and improves code readability.

Copy link
Copy Markdown
Member

@c-bata c-bata left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you for your contribution!

@c-bata c-bata added the code-fix Change that does not change the behavior, such as code refactoring. label Mar 12, 2026
@c-bata c-bata added this to the v4.8.0 milestone Mar 12, 2026
@c-bata c-bata merged commit c0fcd2e into optuna:master Mar 12, 2026
14 checks passed
@acabellom acabellom deleted the fix-fstring-file branch March 12, 2026 10:35
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.

2 participants