Skip to content

Move type-only imports to TYPE_CHECKING in nsgaii/_crossover.py - #6546

Merged
not522 merged 1 commit into
optuna:masterfrom
yasumorishima:fix/crossover-type-checking
Mar 23, 2026
Merged

not522 merged 1 commit into
optuna:masterfrom
yasumorishima:fix/crossover-type-checking

Conversation

@yasumorishima

Copy link
Copy Markdown
Contributor

Motivation

Move type-only imports into the TYPE_CHECKING block to resolve ruff TCH001/TCH003 violations.

Part of #6029.

Description

  • Move Callable, Sequence (TCH003) and BaseCrossover, StudyDirection, FrozenTrial (TCH001) into TYPE_CHECKING block
  • from __future__ import annotations is already present, so all annotation-only imports are safe to defer

Testing

  • ruff check optuna/samplers/nsgaii/_crossover.py --select TCH → All checks passed
  • pytest tests/samplers_tests/test_nsgaii.py → 151 passed

Move Callable, Sequence, BaseCrossover, StudyDirection, and FrozenTrial
imports into the TYPE_CHECKING block. Resolves ruff TCH001/TCH003.

Part of optuna#6029.
@not522 not522 changed the title Move type-only imports to TYPE_CHECKING in nsgaii/_crossover.py Move type-only imports to TYPE_CHECKING in nsgaii/_crossover.py Mar 23, 2026

@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 added the code-fix Change that does not change the behavior, such as code refactoring. label Mar 23, 2026
@not522 not522 added this to the v4.9.0 milestone Mar 23, 2026
@not522
not522 merged commit 2895a1d into optuna:master Mar 23, 2026
13 checks passed
@yasumorishima
yasumorishima deleted the fix/crossover-type-checking branch November 11, 2026 02:38
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