Skip to content

fix(types): use TYPE_CHECKING for BaseDistribution import in _transform.py - #6552

Merged
c-bata merged 1 commit into
optuna:masterfrom
Aliipou:fix/type-checking-transform
Mar 23, 2026
Merged

c-bata merged 1 commit into
optuna:masterfrom
Aliipou:fix/type-checking-transform

Conversation

@Aliipou

@Aliipou Aliipou commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

Part of #6029.

Moves BaseDistribution under TYPE_CHECKING guard in optuna/_transform.py since it is only referenced in type annotations. With from __future__ import annotations, this import is not needed at runtime.

Reduces import time and avoids optional-dependency errors for users who do not have these optional dependencies installed.

…rm.py

Part of #6029.

Moves BaseDistribution under TYPE_CHECKING guard in optuna/_transform.py
since it is only referenced in type annotations. With
from __future__ import annotations, this import is not needed at runtime.

Reduces import time and avoids optional-dependency errors.

@c-bata c-bata left a comment

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.

LGTM.

@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 df77a6b 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