|
1 | 1 | import contextlib
|
2 |
| -from _typeshed import Incomplete, SupportsWrite |
| 2 | +from _typeshed import Incomplete, SupportsRead, SupportsWrite |
3 | 3 | from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping
|
4 | 4 | from types import TracebackType
|
5 | 5 | from typing import Any, ClassVar, Generic, Literal, NoReturn, TypeVar, overload
|
@@ -30,6 +30,7 @@ class TqdmDeprecationWarning(TqdmWarning, DeprecationWarning): ...
|
30 | 30 | class TqdmMonitorWarning(TqdmWarning, RuntimeWarning): ...
|
31 | 31 |
|
32 | 32 | _T = TypeVar("_T")
|
| 33 | +_U = TypeVar("_U") |
33 | 34 |
|
34 | 35 | class tqdm(Comparable, Generic[_T]):
|
35 | 36 | monitor_interval: ClassVar[int]
|
@@ -222,10 +223,16 @@ class tqdm(Comparable, Generic[_T]):
|
222 | 223 | @property
|
223 | 224 | def format_dict(self) -> MutableMapping[str, Any]: ...
|
224 | 225 | def display(self, msg: str | None = None, pos: int | None = None) -> None: ...
|
| 226 | + @overload |
| 227 | + @classmethod |
| 228 | + def wrapattr( |
| 229 | + cls, stream: SupportsRead[_U], method: Literal["read"], total: float | None = None, bytes: bool = True, **tqdm_kwargs |
| 230 | + ) -> contextlib._GeneratorContextManager[SupportsRead[_U]]: ... |
| 231 | + @overload |
225 | 232 | @classmethod
|
226 | 233 | def wrapattr(
|
227 |
| - cls, stream, method: Literal["read", "write"], total: float | None = None, bytes: bool | None = True, **tqdm_kwargs |
228 |
| - ) -> contextlib._GeneratorContextManager[Incomplete]: ... |
| 234 | + cls, stream: SupportsWrite[_U], method: Literal["write"], total: float | None = None, bytes: bool = True, **tqdm_kwargs |
| 235 | + ) -> contextlib._GeneratorContextManager[SupportsWrite[_U]]: ... |
229 | 236 |
|
230 | 237 | @overload
|
231 | 238 | def trange(
|
|
0 commit comments