Skip to content

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

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

Use TYPE_CHECKING for import in pruners/_base.py#6434
not522 merged 2 commits intooptuna:masterfrom
yasumorishima:fix/issue-6029-type-checking-pruners-base

Conversation

@yasumorishima
Copy link
Copy Markdown
Contributor

@yasumorishima yasumorishima commented Feb 12, 2026

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

yasumorishima and others added 2 commits February 12, 2026 17:36
Related: optuna#6029

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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 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
14 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