From 1b89d98f650d412f3f76da07af28c00929b93112 Mon Sep 17 00:00:00 2001 From: Shinichi Hemmi <50256998+Alnusjaponica@users.noreply.github.com> Date: Mon, 25 Sep 2023 00:08:16 +0900 Subject: [PATCH 1/2] Fix type annotation --- optuna/integration/sklearn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/optuna/integration/sklearn.py b/optuna/integration/sklearn.py index 4824c27857..95ce56d672 100644 --- a/optuna/integration/sklearn.py +++ b/optuna/integration/sklearn.py @@ -48,10 +48,10 @@ if not _imports.is_successful(): BaseEstimator = object # NOQA -ArrayLikeType = Union[List, np.ndarray, "pd.Series", spmatrix] +ArrayLikeType = Union[List, np.ndarray, "pd.Series", "spmatrix"] OneDimArrayLikeType = Union[List[float], np.ndarray, "pd.Series"] -TwoDimArrayLikeType = Union[List[List[float]], np.ndarray, "pd.DataFrame", spmatrix] -IterableType = Union[List, "pd.DataFrame", np.ndarray, "pd.Series", spmatrix, None] +TwoDimArrayLikeType = Union[List[List[float]], np.ndarray, "pd.DataFrame", "spmatrix"] +IterableType = Union[List, "pd.DataFrame", np.ndarray, "pd.Series", "spmatrix", None] IndexableType = Union[Iterable, None] _logger = logging.get_logger(__name__) From ee42e7ec0c24499d88efbfaff584de38e88507e0 Mon Sep 17 00:00:00 2001 From: Shinichi Hemmi <50256998+Alnusjaponica@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:22:28 +0900 Subject: [PATCH 2/2] Use `Optional` instead of `Union[*, None]` Co-authored-by: Gen <54583542+gen740@users.noreply.github.com> --- optuna/integration/sklearn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optuna/integration/sklearn.py b/optuna/integration/sklearn.py index 95ce56d672..f5a4b7a329 100644 --- a/optuna/integration/sklearn.py +++ b/optuna/integration/sklearn.py @@ -52,7 +52,7 @@ OneDimArrayLikeType = Union[List[float], np.ndarray, "pd.Series"] TwoDimArrayLikeType = Union[List[List[float]], np.ndarray, "pd.DataFrame", "spmatrix"] IterableType = Union[List, "pd.DataFrame", np.ndarray, "pd.Series", "spmatrix", None] -IndexableType = Union[Iterable, None] +IndexableType = Optional[Iterable] _logger = logging.get_logger(__name__)