Skip to content

Fix typing import issues in scott_parzen_estimator - #6548

Merged
c-bata merged 1 commit into
optuna:masterfrom
rpathade:refactor/type-checking-scott-parzen-estimator
Mar 23, 2026
Merged

c-bata merged 1 commit into
optuna:masterfrom
rpathade:refactor/type-checking-scott-parzen-estimator

Conversation

@rpathade

@rpathade rpathade commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

This PR is part of the type-checking cleanup effort in #6029.

In optuna/importance/_ped_anova/scott_parzen_estimator.py, FrozenTrial is used only for type annotations. Importing it at runtime is unnecessary and can contribute to circular import issues. To follow the project guidance, this PR moves the type-only import under TYPE_CHECKING.

Description of the changes

  • Added from typing import TYPE_CHECKING to optuna/importance/_ped_anova/scott_parzen_estimator.py.
  • Moved from optuna.trial import FrozenTrial into an if TYPE_CHECKING: block.
  • Kept runtime behavior unchanged; only type-checking import behavior is adjusted.

Validation

  • Ran ruff check optuna/importance/_ped_anova/scott_parzen_estimator.py --select TCH
  • Result: All checks passed!

@rpathade
rpathade force-pushed the refactor/type-checking-scott-parzen-estimator branch from 602d1f6 to 1f62715 Compare March 22, 2026 19:02
@rpathade
rpathade marked this pull request as ready for review March 22, 2026 19:54
@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 efd49f5 into optuna:master Mar 23, 2026
12 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