Skip to content

test: move type-only imports in optuna.testing.pytest_storages behind TYPE_CHECKING - #6540

Merged
c-bata merged 1 commit into
optuna:masterfrom
t7r0n:fix/type-checking-testing-pytest-storages-6029
Mar 27, 2026
Merged

c-bata merged 1 commit into
optuna:masterfrom
t7r0n:fix/type-checking-testing-pytest-storages-6029

Conversation

@t7r0n

@t7r0n t7r0n commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • move type-only imports in optuna/testing/pytest_storages.py into a TYPE_CHECKING block
  • keep runtime behavior unchanged while satisfying Ruff TCH checks

Motivation

Testing

  • uv run ruff check optuna/testing/pytest_storages.py --select TCH
  • uv run ruff check optuna/testing/pytest_storages.py
  • uv run ruff format --check optuna/testing/pytest_storages.py
  • uv run mypy optuna/testing/pytest_storages.py
  • uv run pytest tests/storages_tests/test_storages.py -q

Part of #6029

@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 modified the milestone: v4.9.0 Mar 23, 2026
@c-bata c-bata self-assigned this Mar 23, 2026
@@ -8,23 +8,27 @@
import sys
from time import sleep
from typing import Any

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.

Can we also move typing.Any to the if TYPE_CHECKING: ... block?

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.

I'll proceed with merging this PR since this is a nit-picky.

@c-bata c-bata added this to the v4.9.0 milestone Mar 27, 2026
@c-bata
c-bata merged commit 318741d into optuna:master Mar 27, 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