diff --git a/optuna/samplers/_base.py b/optuna/samplers/_base.py index eff85e2a2d..62ee4b0d1c 100644 --- a/optuna/samplers/_base.py +++ b/optuna/samplers/_base.py @@ -1,11 +1,9 @@ from __future__ import annotations import abc +from collections.abc import Callable +from collections.abc import Sequence from typing import Any -from typing import Callable -from typing import Dict -from typing import Optional -from typing import Sequence from typing import TYPE_CHECKING import warnings @@ -59,7 +57,7 @@ def __str__(self) -> str: @abc.abstractmethod def infer_relative_search_space( self, study: Study, trial: FrozenTrial - ) -> Dict[str, BaseDistribution]: + ) -> dict[str, BaseDistribution]: """Infer the search space that will be used by relative sampling in the target trial. This method is called right before :func:`~optuna.samplers.BaseSampler.sample_relative` @@ -86,8 +84,8 @@ def infer_relative_search_space( @abc.abstractmethod def sample_relative( - self, study: Study, trial: FrozenTrial, search_space: Dict[str, BaseDistribution] - ) -> Dict[str, Any]: + self, study: Study, trial: FrozenTrial, search_space: dict[str, BaseDistribution] + ) -> dict[str, Any]: """Sample parameters in a given search space. This method is called once at the beginning of each trial, i.e., right before the @@ -181,7 +179,7 @@ def after_trial( study: Study, trial: FrozenTrial, state: TrialState, - values: Optional[Sequence[float]], + values: Sequence[float] | None, ) -> None: """Trial post-processing.