From bd9cf2a7e59573c03d6c35928a1b0d4946bfbff0 Mon Sep 17 00:00:00 2001 From: nabenabe0928 Date: Tue, 3 Oct 2023 09:55:32 +0200 Subject: [PATCH 1/2] First commit for PR test --- optuna/progress_bar.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/optuna/progress_bar.py b/optuna/progress_bar.py index 86eb453dc4..2e9b265a9a 100644 --- a/optuna/progress_bar.py +++ b/optuna/progress_bar.py @@ -1,6 +1,6 @@ +from __future__ import annotations + import logging -from typing import Any -from typing import Optional from typing import TYPE_CHECKING import warnings @@ -12,7 +12,7 @@ if TYPE_CHECKING: from optuna.study import Study -_tqdm_handler: Optional["_TqdmLoggingHandler"] = None +_tqdm_handler: _TqdmLoggingHandler | None = None # Reference: https://gist.github.com/hvy/8b80c2cedf02b15c24f85d1fa17ebe02 @@ -43,8 +43,8 @@ class _ProgressBar: def __init__( self, is_valid: bool, - n_trials: Optional[int] = None, - timeout: Optional[float] = None, + n_trials: int | None = None, + timeout: float | None = None, ) -> None: if is_valid and n_trials is None and timeout is None: warnings.warn("Progress bar won't be displayed because n_trials and timeout are None.") @@ -72,7 +72,7 @@ def __init__( optuna_logging.disable_default_handler() optuna_logging._get_library_root_logger().addHandler(_tqdm_handler) - def update(self, elapsed_seconds: float, study: "Study") -> None: + def update(self, elapsed_seconds: float, study: Study) -> None: """Update the progress bars if ``is_valid`` is :obj:`True`. Args: From dc9678e4d192a5ad732fef8c7c4c56e19e9c18eb Mon Sep 17 00:00:00 2001 From: nabenabe0928 Date: Tue, 3 Oct 2023 11:02:21 +0200 Subject: [PATCH 2/2] [fix] Get Any back to fix the flake8 error --- optuna/progress_bar.py | 1 + 1 file changed, 1 insertion(+) diff --git a/optuna/progress_bar.py b/optuna/progress_bar.py index 2e9b265a9a..63e0e5b814 100644 --- a/optuna/progress_bar.py +++ b/optuna/progress_bar.py @@ -1,6 +1,7 @@ from __future__ import annotations import logging +from typing import Any from typing import TYPE_CHECKING import warnings