Skip to content

fix: move FrozenTrial import into TYPE_CHECKING block in storages/_callbacks.py#6609

Merged
c-bata merged 2 commits into
optuna:masterfrom
satishkc7:fix/type-checking-callbacks
Apr 3, 2026
Merged

fix: move FrozenTrial import into TYPE_CHECKING block in storages/_callbacks.py#6609
c-bata merged 2 commits into
optuna:masterfrom
satishkc7:fix/type-checking-callbacks

Conversation

@satishkc7

Copy link
Copy Markdown
Contributor

Closes #6029 (partially - one file per PR as requested)

Summary

Moves the FrozenTrial import in optuna/storages/_callbacks.py into a TYPE_CHECKING block, as it is only referenced in type annotations.

from __future__ import annotations is already present, so all annotations are evaluated lazily at runtime and the import is not needed outside of type checking.

Verification

ruff check optuna/storages/_callbacks.py --select TCH
All checks passed!

@c-bata c-bata added the code-fix Change that does not change the behavior, such as code refactoring. label Apr 3, 2026
@c-bata c-bata added this to the v4.9.0 milestone Apr 3, 2026
@c-bata c-bata merged commit 75d02e1 into optuna:master Apr 3, 2026
13 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 TYPE_CHECKING if necessary

2 participants