Skip to content

Use TYPE_CHECKING for import in pruners/_base.py - #6434

Merged
not522 merged 2 commits into
optuna:masterfrom
yasumorishima:fix/issue-6029-type-checking-pruners-base
Feb 13, 2026
Merged

not522 merged 2 commits into
optuna:masterfrom
yasumorishima:fix/issue-6029-type-checking-pruners-base

Conversation

@yasumorishima

@yasumorishima yasumorishima commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part of #6029

Move import optuna under if TYPE_CHECKING: guard in optuna/pruners/_base.py to prevent potential circular import issues.

Changes

  • Add from __future__ import annotations for PEP 563 postponed evaluation
  • Add from typing import TYPE_CHECKING
  • Move import optuna under if TYPE_CHECKING: block

@not522 not522 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!

@not522 not522 changed the title Use TYPE_CHECKING for import in pruners/_base.py Use PTYPE_CHECKINGP for import in pruners/_base.py Feb 13, 2026
@not522 not522 added the code-fix Change that does not change the behavior, such as code refactoring. label Feb 13, 2026
@not522 not522 added this to the v4.8.0 milestone Feb 13, 2026
@not522 not522 changed the title Use PTYPE_CHECKINGP for import in pruners/_base.py Use TYPE_CHECKING for import in pruners/_base.py Feb 13, 2026
@not522
not522 merged commit b764352 into optuna:master Feb 13, 2026
13 checks passed
@yasumorishima
yasumorishima deleted the fix/issue-6029-type-checking-pruners-base branch February 18, 2026 08:02
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