Skip to content

Replace .format() with f-string in progress_bar.py#6328

Merged
c-bata merged 1 commit intooptuna:masterfrom
Nayil97:fix/fstring-progress-bar
Nov 5, 2025
Merged

Replace .format() with f-string in progress_bar.py#6328
c-bata merged 1 commit intooptuna:masterfrom
Nayil97:fix/fstring-progress-bar

Conversation

@Nayil97
Copy link
Copy Markdown
Contributor

@Nayil97 Nayil97 commented Nov 5, 2025

Description

This PR modernizes string formatting in progress_bar.py by replacing the .format() method with f-strings, as suggested in #6305.

Changes

  • Updated progress_bar.py line 105-106 to use f-string syntax
  • Changed "{:.02f}/{} seconds".format(elapsed_seconds, self._timeout) to f"{elapsed_seconds:.02f}/{self._timeout} seconds"
  • No functional changes, only code modernization

Related Issue

Closes #6305

Checklist

  • Code follows project style guidelines
  • Changes are limited to one file as per contribution guidelines
  • Maintains exact same functionality

Addresses optuna#6305 by modernizing string formatting in progress_bar.py
to use f-strings instead of .format() method.
Copilot AI review requested due to automatic review settings November 5, 2025 06:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes string formatting in the progress bar module by replacing an older .format() method call with an f-string, which is the more idiomatic and readable approach in modern Python.

  • Converted .format() string formatting to f-string syntax for elapsed time display

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Collaborator

@kAIto47802 kAIto47802 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 PR. LGTM

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.

@c-bata c-bata added the code-fix Change that does not change the behavior, such as code refactoring. label Nov 5, 2025
@c-bata c-bata added this to the v4.7.0 milestone Nov 5, 2025
@c-bata c-bata merged commit a83caee into optuna:master Nov 5, 2025
20 checks passed
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.

Use f-string and {var_name=} instead of .format and var_name={var_name}

4 participants