Skip to content

Commit

Permalink
Merge pull request optuna#4992 from nabenabe0928/4508/refactor/add-fu…
Browse files Browse the repository at this point in the history
…ture-annotations-for-typing

Add __future__.annotations to progress_bar.py
  • Loading branch information
not522 authored Oct 4, 2023
2 parents 3cca56f + dc9678e commit 429902d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions optuna/progress_bar.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import logging
from typing import Any
from typing import Optional
from typing import TYPE_CHECKING
import warnings

Expand All @@ -12,7 +13,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
Expand Down Expand Up @@ -43,8 +44,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.")
Expand Down Expand Up @@ -72,7 +73,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:
Expand Down

0 comments on commit 429902d

Please sign in to comment.