Skip to content

Use TYPE_CHECKING in pruners/_wilcoxon.py - #6518

Merged
y0z merged 1 commit into
optuna:masterfrom
saivedant169:refactor/type-checking-wilcoxon-pruner
Mar 17, 2026
Merged

y0z merged 1 commit into
optuna:masterfrom
saivedant169:refactor/type-checking-wilcoxon-pruner

Conversation

@saivedant169

Copy link
Copy Markdown
Contributor

Motivation

Part of #6029.

Description

Move optuna and FrozenTrial into the TYPE_CHECKING block in optuna/pruners/_wilcoxon.py. Both are only used in type annotations and docstring examples, not at runtime.

StudyDirection stays at module level since it's used as a value (StudyDirection.MAXIMIZE).

ruff check --select TCH passes clean after the change.

Move optuna and FrozenTrial into TYPE_CHECKING block — both are only
used in type annotations and docstring examples, not at runtime.
StudyDirection stays at module level since it is used as a value
(StudyDirection.MAXIMIZE).

Part of optuna#6029

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

@y0z y0z added the code-fix Change that does not change the behavior, such as code refactoring. label Mar 17, 2026
@y0z y0z added this to the v4.9.0 milestone Mar 17, 2026
@y0z
y0z merged commit e9c5f68 into optuna:master Mar 17, 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