Skip to content

Add acqf import inside a TYPE_CHECKING block#6484

Merged
not522 merged 1 commit intooptuna:masterfrom
acabellom:refactor/type-checking-_gp-optim_sample
Mar 2, 2026
Merged

Add acqf import inside a TYPE_CHECKING block#6484
not522 merged 1 commit intooptuna:masterfrom
acabellom:refactor/type-checking-_gp-optim_sample

Conversation

@acabellom
Copy link
Copy Markdown
Contributor

Motivation

The import of optuna._gp.acqf was used only for type hints.
Moving it under TYPE_CHECKING avoids runtime imports and potential circular dependencies.

Description of the changes

  • Move type-only import to TYPE_CHECKING block in optim_sample.py

Tests

  • ruff check optuna/_gp/optim_sample.py --select TCH

Part of #6029

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 changed the title refactor: add acqf import inside a TYPE_CHECKING block Add acqf import inside a TYPE_CHECKING block Mar 2, 2026
@not522 not522 added the code-fix Change that does not change the behavior, such as code refactoring. label Mar 2, 2026
@not522 not522 added this to the v4.8.0 milestone Mar 2, 2026
@not522 not522 merged commit 5539605 into optuna:master Mar 2, 2026
14 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