Skip to content

Move type-only imports to TYPE_CHECKING in _param_importances.py#6423

Merged
not522 merged 1 commit intooptuna:masterfrom
dotz0ver:fix-type-checking
Jan 26, 2026
Merged

Move type-only imports to TYPE_CHECKING in _param_importances.py#6423
not522 merged 1 commit intooptuna:masterfrom
dotz0ver:fix-type-checking

Conversation

@dotz0ver
Copy link
Copy Markdown
Contributor

Summary
Move type-only imports in optuna/visualization/_param_importances.py into a TYPE_CHECKING block.

Motivation

  • Limits runtime imports by isolating type-only dependencies under TYPE_CHECKING.
  • Clarifies the boundary between imports required at runtime and those used solely for type checking.
  • The implementation follows the guideline proposed in issue Use TYPE_CHECKING if necessary #6029.

Changes

  • Moved type-only imports (Callable, BaseDistribution, BaseImportanceEvaluator, Study, FrozenTrial) into if TYPE_CHECKING:.

Verification

  • Existing visualization tests passed.
  • Pre-commit checks (ruff, formatting, mypy) passed.

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 Move type-only imports to TYPE_CHECKING in visualization/_param_importances.py Move type-only imports to TYPE_CHECKING in _param_importances.py Jan 26, 2026
@not522 not522 added the code-fix Change that does not change the behavior, such as code refactoring. label Jan 26, 2026
@not522 not522 added this to the v4.8.0 milestone Jan 26, 2026
@not522 not522 merged commit 48997cd into optuna:master Jan 26, 2026
15 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