Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tqdm: Improve wrapattr #13361

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions stubs/tqdm/tqdm/std.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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(
Expand Down
Loading