diff --git a/optuna_dashboard/_app.py b/optuna_dashboard/_app.py index ac31e857..140ad8b1 100644 --- a/optuna_dashboard/_app.py +++ b/optuna_dashboard/_app.py @@ -12,6 +12,7 @@ import typing from typing import Any from typing import Callable from typing import cast +from typing import Dict from typing import Optional from typing import TypeVar from typing import Union @@ -48,7 +49,7 @@ if typing.TYPE_CHECKING: except ImportError: FrozenStudy = None # type: ignore -BottleViewReturn = Union[str, bytes, dict[str, Any], BaseResponse] +BottleViewReturn = Union[str, bytes, Dict[str, Any], BaseResponse] BottleView = TypeVar("BottleView", bound=Callable[..., BottleViewReturn]) logger = logging.getLogger(__name__) diff --git a/optuna_dashboard/_cached_extra_study_property.py b/optuna_dashboard/_cached_extra_study_property.py index 105a1428..c8af8ec5 100644 --- a/optuna_dashboard/_cached_extra_study_property.py +++ b/optuna_dashboard/_cached_extra_study_property.py @@ -2,21 +2,27 @@ from __future__ import annotations import copy import threading +from typing import List from typing import Optional +from typing import Set +from typing import Tuple +from typing import TYPE_CHECKING from optuna.distributions import BaseDistribution from optuna.trial import FrozenTrial from optuna.trial import TrialState -SearchSpaceSetT = set[tuple[str, BaseDistribution]] -SearchSpaceListT = list[tuple[str, BaseDistribution]] - # In-memory cache cached_extra_study_property_cache_lock = threading.Lock() cached_extra_study_property_cache: dict[int, "_CachedExtraStudyProperty"] = {} +if TYPE_CHECKING: + SearchSpaceSetT = Set[Tuple[str, BaseDistribution]] + SearchSpaceListT = List[Tuple[str, BaseDistribution]] + + def get_cached_extra_study_property( study_id: int, trials: list[FrozenTrial] ) -> tuple[SearchSpaceListT, SearchSpaceListT, list[tuple[str, bool]], bool]: diff --git a/visual_regression_test.py b/visual_regression_test.py index 89e70f23..a8b16502 100644 --- a/visual_regression_test.py +++ b/visual_regression_test.py @@ -1,4 +1,5 @@ from __future__ import annotations + import argparse import asyncio import os