Skip to content

Use TYPE_CHECKING in optuna/samplers/_ga/_base.py - #6560

Merged
c-bata merged 1 commit into
optuna:masterfrom
nightcityblade:fix/issue-6029
Mar 23, 2026
Merged

c-bata merged 1 commit into
optuna:masterfrom
nightcityblade:fix/issue-6029

Conversation

@nightcityblade

Copy link
Copy Markdown

Move type-only imports (Study, FrozenTrial) under TYPE_CHECKING in optuna/samplers/_ga/_base.py and replace optuna.Study with a direct Study import.

Part of #6029

Changes:

  • Move FrozenTrial and Study imports under if TYPE_CHECKING
  • Replace optuna.Study references with Study in type annotations
  • Keep BaseSampler and TrialState as runtime imports (used at runtime)
  • ruff check passes
  • pytest tests/samplers_tests/test_nsgaii.py — 151 passed

Move type-only imports (Study, FrozenTrial) under TYPE_CHECKING
and replace optuna.Study with direct Study import.

See optuna#6029
@c-bata c-bata added the code-fix Change that does not change the behavior, such as code refactoring. label Mar 23, 2026
@c-bata c-bata added this to the v4.9.0 milestone Mar 23, 2026
@c-bata
c-bata merged commit e8b6796 into optuna:master Mar 23, 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.

2 participants