Improve tqdm.contrib.logging context managers (#8251)

This commit is contained in:
Alex Waygood
2022-07-07 10:28:28 +01:00
committed by GitHub
parent ccdb558af9
commit 42c5633bf6

View File

@@ -1,10 +1,19 @@
import logging
from collections.abc import Iterator, Sequence
from typing import Any
from _typeshed import Incomplete
from collections.abc import Callable, Sequence
from contextlib import _GeneratorContextManager
from typing import Any, TypeVar, overload
from ..std import tqdm as std_tqdm
_TqdmT = TypeVar("_TqdmT", bound=std_tqdm[Any])
def logging_redirect_tqdm(
loggers: Sequence[logging.Logger] | None = ..., tqdm_class: type[std_tqdm[Any]] = ...
) -> Iterator[None]: ...
def tqdm_logging_redirect(*args, **kwargs) -> Iterator[None]: ...
) -> _GeneratorContextManager[None]: ...
# TODO type *args, **kwargs here more precisely
@overload
def tqdm_logging_redirect(*args, tqdm_class: Callable[..., _TqdmT], **kwargs) -> _GeneratorContextManager[_TqdmT]: ...
@overload
def tqdm_logging_redirect(*args, **kwargs) -> _GeneratorContextManager[std_tqdm[Incomplete]]: ...