Skip to content

Changed the old .format code to the new f string format in the test_journal.py#6312

Merged
not522 merged 2 commits intooptuna:masterfrom
Zrahay:bug/update
Oct 24, 2025
Merged

Changed the old .format code to the new f string format in the test_journal.py#6312
not522 merged 2 commits intooptuna:masterfrom
Zrahay:bug/update

Conversation

@Zrahay
Copy link
Copy Markdown
Contributor

@Zrahay Zrahay commented Oct 22, 2025

Motivation

Now that Optuna has dropped the support for Python 3.8 we can use modern f string syntax in the codebase which replaces the old .format method.

Description Of The Changes

Replaced the occurence of the old '.format()' formatting technique with the new f string technique in the test_journal.py file. The file is present at the location tests/storage_tests/journal_tests/test_journal.py.

No other functional changes were made in this.

@Zrahay
Copy link
Copy Markdown
Contributor Author

Zrahay commented Oct 22, 2025

Hey there! If there's any sort of ambiguity or errors in my code or maybe if I missed some important step, please do let me know. I'll fix that as soon as possible.

Cheers!

return journal_redis_storage
else:
raise RuntimeError("Unknown log storage type: {}".format(self.storage_type))
raise RuntimeError(f"Unknown Log Storage Type: {self.storage_type}")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your PR! Could you keep the behavior as it was before?

Suggested change
raise RuntimeError(f"Unknown Log Storage Type: {self.storage_type}")
raise RuntimeError(f"Unknown log storage type: {self.storage_type}")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey there! Kinda confused as to what do you mean by keeping the behaviour as it was before? Do you want me to change the technique back to the .format() method?

I'm sorry if it seems a pretty bad question, I'm new to open source so can't understand what did you mean by this.

Thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you leave the error message as is? That is, stop using capitalize. Focus this PR's changes solely on changing from format to f-string.

@not522 not522 changed the title Changed the old .format code to the new f string format in the test_j… Changed the old .format code to the new f string format in the test_journal.py Oct 23, 2025
@not522 not522 self-assigned this Oct 23, 2025
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 Oct 23, 2025
Copy link
Copy Markdown
Member

@not522 not522 left a comment

Choose a reason for hiding this comment

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

LGTM!

@not522 not522 added this to the v4.6.0 milestone Oct 24, 2025
@not522 not522 merged commit a4691d8 into optuna:master Oct 24, 2025
12 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.

3 participants