Skip to content

Use TYPE_CHECKING in pruners/_threshold.py#6487

Merged
not522 merged 1 commit intooptuna:masterfrom
LuciferDono:refactor/type-checking-pruners-threshold
Mar 2, 2026
Merged

Use TYPE_CHECKING in pruners/_threshold.py#6487
not522 merged 1 commit intooptuna:masterfrom
LuciferDono:refactor/type-checking-pruners-threshold

Conversation

@LuciferDono
Copy link
Copy Markdown
Contributor

Motivation

Refs #6029

Description of the changes

Move import optuna into a TYPE_CHECKING block in optuna/pruners/_threshold.py, since it is only used in type annotations and the file already has from __future__ import annotations. Replaced string-quoted annotations with direct references.

Verified with ruff check optuna/pruners/_threshold.py --select TCH.

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 Use TYPE_CHECKING in pruners/_threshold.py Use TYPE_CHECKING in pruners/_threshold.py 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 4eea228 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