diff --git a/stubs/tqdm/tqdm/std.pyi b/stubs/tqdm/tqdm/std.pyi index 297b01784d10..8ffbb0eaa60e 100644 --- a/stubs/tqdm/tqdm/std.pyi +++ b/stubs/tqdm/tqdm/std.pyi @@ -1,5 +1,5 @@ import contextlib -from _typeshed import Incomplete, SupportsWrite +from _typeshed import Incomplete, SupportsRead, SupportsWrite from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping from types import TracebackType from typing import Any, ClassVar, Generic, Literal, NoReturn, TypeVar, overload @@ -30,6 +30,7 @@ class TqdmDeprecationWarning(TqdmWarning, DeprecationWarning): ... class TqdmMonitorWarning(TqdmWarning, RuntimeWarning): ... _T = TypeVar("_T") +_U = TypeVar("_U") class tqdm(Comparable, Generic[_T]): monitor_interval: ClassVar[int] @@ -222,10 +223,16 @@ class tqdm(Comparable, Generic[_T]): @property def format_dict(self) -> MutableMapping[str, Any]: ... def display(self, msg: str | None = None, pos: int | None = None) -> None: ... + @overload + @classmethod + def wrapattr( + cls, stream: SupportsRead[_U], method: Literal["read"], total: float | None = None, bytes: bool = True, **tqdm_kwargs + ) -> contextlib._GeneratorContextManager[SupportsRead[_U]]: ... + @overload @classmethod def wrapattr( - cls, stream, method: Literal["read", "write"], total: float | None = None, bytes: bool | None = True, **tqdm_kwargs - ) -> contextlib._GeneratorContextManager[Incomplete]: ... + cls, stream: SupportsWrite[_U], method: Literal["write"], total: float | None = None, bytes: bool = True, **tqdm_kwargs + ) -> contextlib._GeneratorContextManager[SupportsWrite[_U]]: ... @overload def trange(