Skip to content

Move type-only imports in optuna.samplers._partial_fixed to TYPE_CHECKING - #6527

Merged
c-bata merged 1 commit into
optuna:masterfrom
t7r0n:fix/type-checking-partial-fixed-6029
Mar 23, 2026
Merged

c-bata merged 1 commit into
optuna:masterfrom
t7r0n:fix/type-checking-partial-fixed-6029

Conversation

@t7r0n

@t7r0n t7r0n commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Motivation

Part of #6029.

ruff check --select TCH reports type-checking import violations in optuna/samplers/_partial_fixed.py.

What I changed

  • Moved type-only imports to the if TYPE_CHECKING: block in optuna/samplers/_partial_fixed.py:
    • Sequence
    • BaseDistribution
    • FrozenTrial
    • TrialState
  • Kept runtime behavior unchanged (no functional logic changes).

Validation

ruff check optuna/samplers/_partial_fixed.py --select TCH
ruff check optuna/samplers/_partial_fixed.py
ruff format --check optuna/samplers/_partial_fixed.py
pytest tests/samplers_tests/test_partial_fixed.py -q
mypy optuna/samplers/_partial_fixed.py

All commands passed locally.

@c-bata c-bata 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.

@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 c2a2273 into optuna:master Mar 23, 2026
13 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