Add stubs for tqdm (#8235)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Daniel Rembiszewski
2022-07-05 20:34:11 +03:00
committed by GitHub
parent d1d87f0d87
commit c23cb7be75
35 changed files with 1170 additions and 0 deletions

View File

@@ -71,6 +71,7 @@
"stubs/slumber",
"stubs/SQLAlchemy",
"stubs/stripe",
"stubs/tqdm",
"stubs/ttkthemes",
"stubs/urllib3",
"stubs/vobject"

View File

@@ -0,0 +1,6 @@
tensorflow
pandas
dask
rich
requests
slack-sdk

View File

@@ -0,0 +1 @@
tqdm.contrib.discord

1
stubs/tqdm/METADATA.toml Normal file
View File

@@ -0,0 +1 @@
version = "4.64.*"

View File

@@ -0,0 +1,20 @@
from _typeshed import Incomplete
from ._monitor import TMonitor as TMonitor, TqdmSynchronisationWarning as TqdmSynchronisationWarning
from ._tqdm_pandas import tqdm_pandas as tqdm_pandas
from .cli import main as main
from .gui import tqdm as tqdm_gui, trange as tgrange
from .notebook import tqdm_notebook as tqdm_notebook_cls
from .std import (
TqdmDeprecationWarning as TqdmDeprecationWarning,
TqdmExperimentalWarning as TqdmExperimentalWarning,
TqdmKeyError as TqdmKeyError,
TqdmMonitorWarning as TqdmMonitorWarning,
TqdmTypeError as TqdmTypeError,
TqdmWarning as TqdmWarning,
tqdm as tqdm,
trange as trange,
)
def tqdm_notebook(*args, **kwargs) -> tqdm_notebook_cls[Incomplete]: ...
def tnrange(*args, **kwargs) -> tqdm_notebook_cls[int]: ...

View File

View File

@@ -0,0 +1,4 @@
from .cli import *
# Names in __all__ with no definition:
# main

View File

@@ -0,0 +1,16 @@
from _typeshed import Incomplete
from threading import Thread
class TqdmSynchronisationWarning(RuntimeWarning): ...
class TMonitor(Thread):
daemon: bool
woken: int
tqdm_cls: type[Incomplete]
sleep_interval: float
was_killed: Incomplete
def __init__(self, tqdm_cls: type[Incomplete], sleep_interval: float) -> None: ...
def exit(self): ...
def get_instances(self): ...
def run(self) -> None: ...
def report(self): ...

11
stubs/tqdm/tqdm/_tqdm.pyi Normal file
View File

@@ -0,0 +1,11 @@
from .std import *
from .std import TqdmDeprecationWarning as TqdmDeprecationWarning
# Names in __all__ with no definition:
# TqdmExperimentalWarning
# TqdmKeyError
# TqdmMonitorWarning
# TqdmTypeError
# TqdmWarning
# tqdm
# trange

View File

@@ -0,0 +1,7 @@
from .gui import *
# Names in __all__ with no definition:
# tgrange
# tqdm
# tqdm_gui
# trange

View File

@@ -0,0 +1,7 @@
from .notebook import *
# Names in __all__ with no definition:
# tnrange
# tqdm
# tqdm_notebook
# trange

View File

@@ -0,0 +1 @@
def tqdm_pandas(tclass, **tqdm_kwargs) -> None: ...

View File

@@ -0,0 +1,10 @@
from .std import TqdmDeprecationWarning as TqdmDeprecationWarning
from .utils import (
CUR_OS as CUR_OS,
IS_NIX as IS_NIX,
IS_WIN as IS_WIN,
RE_ANSI as RE_ANSI,
Comparable as Comparable,
FormatReplace as FormatReplace,
SimpleTextIOWrapper as SimpleTextIOWrapper,
)

206
stubs/tqdm/tqdm/asyncio.pyi Normal file
View File

@@ -0,0 +1,206 @@
from _typeshed import Incomplete, Self, SupportsWrite
from collections.abc import Awaitable, Callable, Generator, Iterable, Iterator, Mapping
from typing import Generic, NoReturn, TypeVar, overload
from .std import tqdm as std_tqdm
_T = TypeVar("_T")
class tqdm_asyncio(Generic[_T], std_tqdm[_T]):
iterable_awaitable: bool
iterable_next: Callable[[], _T | Awaitable[_T]]
iterable_iterator: Iterator[_T]
def __aiter__(self: Self) -> Self: ...
async def __anext__(self) -> Awaitable[_T]: ...
def send(self, *args, **kwargs): ...
@classmethod
def as_completed(
cls,
fs: Iterable[Awaitable[_T]],
*,
loop: bool | None = ...,
timeout: float | None = ...,
total: int | None = ...,
desc: str | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
) -> Generator[Incomplete, Incomplete, None]: ...
@classmethod
async def gather(
cls,
*fs: Awaitable[_T],
loop: bool | None = ...,
timeout: float | None = ...,
total: int | None = ...,
iterable: Iterable[_T] = ...,
desc: str | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
): ...
@overload
def __init__(
self,
iterable: Iterable[_T],
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
**kwargs,
) -> None: ...
@overload
def __init__(
self: tqdm_asyncio[NoReturn],
iterable: None = ...,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
**kwargs,
) -> None: ...
@overload
def tarange(
start: int,
stop: int,
step: int | None = ...,
*,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
) -> tqdm_asyncio[int]: ...
@overload
def tarange(
stop: int,
*,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
) -> tqdm_asyncio[int]: ...
tqdm = tqdm_asyncio
trange = tarange

1
stubs/tqdm/tqdm/auto.pyi Normal file
View File

@@ -0,0 +1 @@
from .asyncio import tqdm as tqdm, trange as trange

View File

@@ -0,0 +1 @@
from .std import tqdm as tqdm, trange as trange

3
stubs/tqdm/tqdm/cli.pyi Normal file
View File

@@ -0,0 +1,3 @@
from collections.abc import Sequence
def main(fp=..., argv: Sequence[str] | None = ...) -> None: ...

View File

@@ -0,0 +1,13 @@
from _typeshed import Incomplete
from collections.abc import Callable, Generator
from ..utils import ObjectWrapper
class DummyTqdmFile(ObjectWrapper):
def __init__(self, wrapped) -> None: ...
def write(self, x, nolock: bool = ...) -> None: ...
def __del__(self) -> None: ...
def tenumerate(iterable, start: int = ..., total: Incomplete | None = ..., tqdm_class: type[Incomplete] = ..., **tqdm_kwargs): ...
def tzip(iter1, *iter2plus, **tqdm_kwargs) -> Generator[Incomplete, None, None]: ...
def tmap(function: Callable[..., Incomplete], *sequences, **tqdm_kwargs) -> Generator[Incomplete, None, None]: ...

View File

@@ -0,0 +1 @@
from ..auto import tqdm as tqdm, trange as trange

View File

@@ -0,0 +1,2 @@
def thread_map(fn, *iterables, **tqdm_kwargs): ...
def process_map(fn, *iterables, **tqdm_kwargs): ...

View File

@@ -0,0 +1,31 @@
from _typeshed import Incomplete
from typing import Generic, TypeVar
from ..auto import tqdm as tqdm_auto
from .utils_worker import MonoWorker
class DiscordIO(MonoWorker):
text: Incomplete
message: Incomplete
def __init__(self, token, channel_id) -> None: ...
def write(self, s): ...
_T = TypeVar("_T")
class tqdm_discord(Generic[_T], tqdm_auto[_T]):
dio: Incomplete
def __init__(self, *args, **kwargs) -> None: ...
def display(
self,
msg: str | None = ...,
pos: int | None = ...,
close: bool = ...,
bar_style: Incomplete = ...,
check_delay: bool = ...,
) -> None: ...
def clear(self, *args, **kwargs) -> None: ...
def tdrange(*args, **kwargs) -> tqdm_discord[int]: ...
tqdm = tqdm_discord
trange = tdrange

View File

@@ -0,0 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Generator, Iterable
def product(*iterables: Iterable[Incomplete], **tqdm_kwargs) -> Generator[Incomplete, None, None]: ...

View File

@@ -0,0 +1,10 @@
import logging
from collections.abc import Iterator, Sequence
from typing import Any
from ..std import tqdm as std_tqdm
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]: ...

View File

@@ -0,0 +1,25 @@
from _typeshed import Incomplete
from typing import Generic, TypeVar
from ..auto import tqdm as tqdm_auto
from .utils_worker import MonoWorker
class SlackIO(MonoWorker):
client: Incomplete
text: Incomplete
message: Incomplete
def __init__(self, token, channel) -> None: ...
def write(self, s): ...
_T = TypeVar("_T")
class tqdm_slack(Generic[_T], tqdm_auto[_T]):
sio: Incomplete
def __init__(self, *args, **kwargs) -> None: ...
def display(self, *, msg: str | None = ..., pos: int | None = ..., close: bool = ..., bar_style: Incomplete = ..., check_delay: bool = ...) -> None: ... # type: ignore[override]
def clear(self, *args, **kwargs) -> None: ...
def tsrange(*args, **kwargs) -> tqdm_slack[int]: ...
tqdm = tqdm_slack
trange = tsrange

View File

@@ -0,0 +1,31 @@
from _typeshed import Incomplete
from typing import Generic, TypeVar
from ..auto import tqdm as tqdm_auto
from .utils_worker import MonoWorker
class TelegramIO(MonoWorker):
API: str
token: Incomplete
chat_id: Incomplete
session: Incomplete
text: Incomplete
def __init__(self, token, chat_id) -> None: ...
@property
def message_id(self): ...
def write(self, s: str) -> Incomplete | None: ...
def delete(self): ...
_T = TypeVar("_T")
class tqdm_telegram(Generic[_T], tqdm_auto[_T]):
tgio: Incomplete
def __init__(self, *args, **kwargs) -> None: ...
def display(self, *, msg: str | None = ..., pos: int | None = ..., close: bool = ..., bar_style: Incomplete = ..., check_delay: bool = ...) -> None: ... # type: ignore[override]
def clear(self, *args, **kwargs) -> None: ...
def close(self) -> None: ...
def ttgrange(*args, **kwargs) -> tqdm_telegram[int]: ...
tqdm = tqdm_telegram
trange = ttgrange

View File

@@ -0,0 +1,15 @@
from _typeshed import Incomplete
from collections import deque
from collections.abc import Callable
from concurrent.futures import Future, ThreadPoolExecutor
from typing import TypeVar
from typing_extensions import ParamSpec
_P = ParamSpec("_P")
_R = TypeVar("_R")
class MonoWorker:
pool: ThreadPoolExecutor
futures: deque[Future[Incomplete]]
def __init__(self) -> None: ...
def submit(self, func: Callable[_P, _R], *args: _P.args, **kwargs: _P.kwargs) -> Future[_R]: ...

12
stubs/tqdm/tqdm/dask.pyi Normal file
View File

@@ -0,0 +1,12 @@
from _typeshed import Incomplete
from typing import Any
from typing_extensions import TypeAlias
_Callback: TypeAlias = Any # Actually dask.callbacks.Callback
class TqdmCallback(_Callback):
tqdm_class: type[Incomplete]
def __init__(
self, start: Incomplete | None = ..., pretask: Incomplete | None = ..., tqdm_class: type[Incomplete] = ..., **tqdm_kwargs
) -> None: ...
def display(self) -> None: ...

90
stubs/tqdm/tqdm/gui.pyi Normal file
View File

@@ -0,0 +1,90 @@
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable, Mapping
from typing import Generic, NoReturn, TypeVar, overload
from .std import tqdm as std_tqdm
_T = TypeVar("_T")
class tqdm_gui(Generic[_T], std_tqdm[_T]):
mpl: Incomplete
plt: Incomplete
toolbar: Incomplete
mininterval: Incomplete
xdata: Incomplete
ydata: Incomplete
zdata: Incomplete
hspan: Incomplete
wasion: Incomplete
ax: Incomplete
disable: bool
def close(self) -> None: ...
def clear(self, *_, **__) -> None: ...
def display(self, *_, **__) -> None: ...
@overload
def __init__(
self,
iterable: Iterable[_T],
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
**kwargs,
) -> None: ...
@overload
def __init__(
self: tqdm_gui[NoReturn],
iterable: None = ...,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
**kwargs,
) -> None: ...
def tgrange(*args, **kwargs) -> tqdm_gui[int]: ...
tqdm = tqdm_gui
trange = tgrange

29
stubs/tqdm/tqdm/keras.pyi Normal file
View File

@@ -0,0 +1,29 @@
from _typeshed import Incomplete
from typing import Any
from typing_extensions import TypeAlias
_Callback: TypeAlias = Any # Actually tensorflow.keras.callbacks.Callback
class TqdmCallback(_Callback):
@staticmethod
def bar2callback(bar, pop: Incomplete | None = ..., delta=...): ...
tqdm_class: Incomplete
epoch_bar: Incomplete
on_epoch_end: Incomplete
batches: Incomplete
verbose: Incomplete
batch_bar: Incomplete
on_batch_end: Incomplete
def __init__(
self,
epochs: Incomplete | None = ...,
data_size: Incomplete | None = ...,
batch_size: Incomplete | None = ...,
verbose: int = ...,
tqdm_class=...,
**tqdm_kwargs,
) -> None: ...
def on_train_begin(self, *_, **__) -> None: ...
def on_epoch_begin(self, epoch, *_, **__) -> None: ...
def on_train_end(self, *_, **__) -> None: ...
def display(self) -> None: ...

View File

@@ -0,0 +1,94 @@
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable, Iterator, Mapping
from typing import Generic, TypeVar, overload
from .std import tqdm as std_tqdm, trange as trange
_T = TypeVar("_T")
class tqdm_notebook(Generic[_T], std_tqdm[_T]):
@staticmethod
def status_printer(
_: SupportsWrite[str] | None, total: float | None = ..., desc: str | None = ..., ncols: int | None = ...
): ...
displayed: bool
def display(
self,
msg: str | None = ...,
pos: int | None = ...,
close: bool = ...,
bar_style: str | None = ...,
check_delay: bool = ...,
) -> None: ...
@property
def colour(self): ...
@colour.setter
def colour(self, bar_color: str) -> None: ...
disp: Incomplete
ncols: Incomplete
container: Incomplete
@overload
def __init__(
self,
iterable: Iterable[_T] | None,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
) -> None: ...
@overload
def __init__(
self,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
) -> None: ...
def __iter__(self) -> Iterator[_T]: ...
def update(self, n: int = ...): ... # type: ignore[override]
def close(self) -> None: ...
def clear(self, *_, **__) -> None: ...
def reset(self, total: float | None = ...): ...
tqdm = tqdm_notebook
tnrange = trange

98
stubs/tqdm/tqdm/rich.pyi Normal file
View File

@@ -0,0 +1,98 @@
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable, Mapping
from typing import Any, Generic, NoReturn, TypeVar, overload
from typing_extensions import TypeAlias
from .std import tqdm as std_tqdm
_ProgressColumn: TypeAlias = Any # Actually rich.progress.ProgressColumn
class FractionColumn(_ProgressColumn):
unit_scale: bool
unit_divisor: int
def __init__(self, unit_scale: bool = ..., unit_divisor: int = ...) -> None: ...
def render(self, task): ...
class RateColumn(_ProgressColumn):
unit: str
unit_scale: bool
unit_divisor: int
def __init__(self, unit: str = ..., unit_scale: bool = ..., unit_divisor: int = ...) -> None: ...
def render(self, task): ...
_T = TypeVar("_T")
class tqdm_rich(Generic[_T], std_tqdm[_T]):
def close(self) -> None: ...
def clear(self, *_, **__) -> None: ...
def display(self, *_, **__) -> None: ...
def reset(self, total: Incomplete | None = ...) -> None: ...
@overload
def __init__(
self,
iterable: Iterable[_T],
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
**kwargs,
) -> None: ...
@overload
def __init__(
self: tqdm_rich[NoReturn],
iterable: None = ...,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
**kwargs,
) -> None: ...
def trrange(*args, **kwargs) -> tqdm_rich[int]: ...
tqdm = tqdm_rich
trange = trrange

274
stubs/tqdm/tqdm/std.pyi Normal file
View File

@@ -0,0 +1,274 @@
import contextlib
from _typeshed import Incomplete, Self, SupportsWrite
from collections.abc import Callable, Iterable, Iterator, Mapping, MutableMapping
from typing import Any, ClassVar, Generic, NoReturn, TypeVar, overload
from typing_extensions import Literal
from .utils import Comparable
class TqdmTypeError(TypeError): ...
class TqdmKeyError(KeyError): ...
class TqdmWarning(Warning):
def __init__(self, msg, fp_write: Incomplete | None = ..., *a, **k) -> None: ...
class TqdmExperimentalWarning(TqdmWarning, FutureWarning): ...
class TqdmDeprecationWarning(TqdmWarning, DeprecationWarning): ...
class TqdmMonitorWarning(TqdmWarning, RuntimeWarning): ...
_T = TypeVar("_T")
class tqdm(Generic[_T], Iterable[_T], Comparable):
monitor_interval: ClassVar[int]
@staticmethod
def format_sizeof(num: float, suffix: str = ..., divisor: float = ...) -> str: ...
@staticmethod
def format_interval(t: float) -> str: ...
@staticmethod
def format_num(n: float) -> str: ...
@staticmethod
def status_printer(file: SupportsWrite[str]) -> Callable[[str], None]: ...
@staticmethod
def format_meter(
n: float,
total: float,
elapsed: float,
ncols: int | None = ...,
prefix: str | None = ...,
ascii: bool | str | None = ...,
unit: str | None = ...,
unit_scale: bool | float | None = ...,
rate: float | None = ...,
bar_format: str | None = ...,
postfix: str | Mapping[str, object] | None = ...,
unit_divisor: float | None = ...,
initial: float | None = ...,
colour: str | None = ...,
) -> str: ...
@overload
def __init__(
self,
iterable: Iterable[_T],
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
**kwargs,
) -> None: ...
@overload
def __init__(
self: tqdm[NoReturn],
iterable: None = ...,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
**kwargs,
) -> None: ...
def __new__(cls: type[Self], *_, **__) -> Self: ...
@classmethod
def write(cls, s: str, file: SupportsWrite[str] | None = ..., end: str = ..., nolock: bool = ...) -> None: ...
@classmethod
def external_write_mode(
cls, file: SupportsWrite[str] | None = ..., nolock: bool = ...
) -> contextlib._GeneratorContextManager[None]: ...
@classmethod
def set_lock(cls, lock) -> None: ...
@classmethod
def get_lock(cls): ...
@classmethod
def pandas(
cls,
*,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
) -> None: ...
iterable: Incomplete
disable: Incomplete
pos: Incomplete
n: Incomplete
total: Incomplete
leave: Incomplete
desc: Incomplete
fp: Incomplete
ncols: Incomplete
nrows: Incomplete
mininterval: Incomplete
maxinterval: Incomplete
miniters: Incomplete
dynamic_miniters: Incomplete
ascii: Incomplete
unit: Incomplete
unit_scale: Incomplete
unit_divisor: Incomplete
initial: Incomplete
lock_args: Incomplete
delay: Incomplete
gui: Incomplete
dynamic_ncols: Incomplete
smoothing: Incomplete
bar_format: Incomplete
postfix: Incomplete
colour: Incomplete
last_print_n: Incomplete
sp: Incomplete
last_print_t: Incomplete
start_t: Incomplete
def __bool__(self) -> bool: ...
def __nonzero__(self) -> bool: ...
def __len__(self) -> int: ...
def __reversed__(self) -> Iterator[_T]: ...
def __contains__(self, item: object) -> bool: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, exc_type: object, exc_value: object, traceback: object) -> None: ...
def __del__(self) -> None: ...
def __hash__(self) -> int: ...
def __iter__(self) -> Iterator[_T]: ...
def update(self, n: float | None = ...) -> bool | None: ...
def close(self) -> None: ...
def clear(self, nolock: bool = ...) -> None: ...
def refresh(
self, nolock: bool = ..., lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...
) -> None: ...
def unpause(self) -> None: ...
def reset(self, total: float | None = ...) -> None: ...
def set_description(self, desc: str | None = ..., refresh: bool | None = ...) -> None: ...
def set_description_str(self, desc: str | None = ..., refresh: bool | None = ...) -> None: ...
def set_postfix(self, ordered_dict: Mapping[str, object] | None = ..., refresh: bool | None = ..., **kwargs) -> None: ...
def set_postfix_str(self, s: str = ..., refresh: bool = ...) -> None: ...
def moveto(self, n) -> None: ...
@property
def format_dict(self) -> MutableMapping[str, Any]: ...
def display(self, msg: str | None = ..., pos: int | None = ...) -> None: ...
@classmethod
def wrapattr(
cls, stream, method: Literal["read", "write"], total: float | None = ..., bytes: bool | None = ..., **tqdm_kwargs
) -> contextlib._GeneratorContextManager[Incomplete]: ...
@overload
def trange(
start: int,
stop: int,
step: int | None = ...,
*,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
) -> tqdm[int]: ...
@overload
def trange(
stop: int,
*,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
) -> tqdm[int]: ...

91
stubs/tqdm/tqdm/tk.pyi Normal file
View File

@@ -0,0 +1,91 @@
from _typeshed import Incomplete, SupportsWrite
from collections.abc import Iterable, Mapping
from typing import Generic, NoReturn, TypeVar, overload
from .std import tqdm as std_tqdm
_T = TypeVar("_T")
class tqdm_tk(Generic[_T], std_tqdm[_T]):
@overload
def __init__(
self,
iterable: Iterable[_T],
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
grab=...,
tk_parent=...,
cancel_callback=...,
**kwargs,
) -> None: ...
@overload
def __init__(
self: tqdm_tk[NoReturn],
iterable: None = ...,
desc: str | None = ...,
total: float | None = ...,
leave: bool = ...,
file: SupportsWrite[str] | None = ...,
ncols: int | None = ...,
mininterval: float = ...,
maxinterval: float = ...,
miniters: float | None = ...,
ascii: bool | str | None = ...,
disable: bool = ...,
unit: str = ...,
unit_scale: bool | float = ...,
dynamic_ncols: bool = ...,
smoothing: float = ...,
bar_format: str | None = ...,
initial: float = ...,
position: int | None = ...,
postfix: Mapping[str, object] | str | None = ...,
unit_divisor: float = ...,
write_bytes: bool | None = ...,
lock_args: tuple[bool | None, float | None] | tuple[bool | None] | None = ...,
nrows: int | None = ...,
colour: str | None = ...,
delay: float | None = ...,
gui: bool = ...,
grab=...,
tk_parent=...,
cancel_callback=...,
**kwargs,
) -> None: ...
disable: bool
def close(self) -> None: ...
def clear(self, *_, **__) -> None: ...
def display(self, *_, **__) -> None: ...
def set_description(self, desc: str | None = ..., refresh: bool | None = ...) -> None: ...
desc: Incomplete
def set_description_str(self, desc: str | None = ..., refresh: bool | None = ...) -> None: ...
def cancel(self) -> None: ...
def reset(self, total: Incomplete | None = ...) -> None: ...
def ttkrange(*args, **kwargs) -> tqdm_tk[int]: ...
tqdm = tqdm_tk
trange = ttkrange

54
stubs/tqdm/tqdm/utils.pyi Normal file
View File

@@ -0,0 +1,54 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Pattern, Protocol, TypeVar
from typing_extensions import ParamSpec
CUR_OS: str
IS_WIN: bool
IS_NIX: bool
RE_ANSI: Pattern[str]
class FormatReplace:
replace: str
format_called: int
def __init__(self, replace: str = ...) -> None: ...
def __format__(self, _) -> str: ...
class _Has__Comparable(Protocol):
_comparable: Incomplete
class Comparable:
_comparable: Incomplete
def __lt__(self, other: _Has__Comparable) -> bool: ...
def __le__(self, other: _Has__Comparable) -> bool: ...
def __eq__(self, other: _Has__Comparable) -> bool: ... # type: ignore[override]
def __ne__(self, other: _Has__Comparable) -> bool: ... # type: ignore[override]
def __gt__(self, other: _Has__Comparable) -> bool: ...
def __ge__(self, other: _Has__Comparable) -> bool: ...
class ObjectWrapper:
def __getattr__(self, name: str): ...
def __setattr__(self, name: str, value) -> None: ...
def wrapper_getattr(self, name): ...
def wrapper_setattr(self, name, value): ...
def __init__(self, wrapped) -> None: ...
class SimpleTextIOWrapper(ObjectWrapper):
def __init__(self, wrapped, encoding) -> None: ...
def write(self, s: str): ...
def __eq__(self, other: object) -> bool: ...
_P = ParamSpec("_P")
_R = TypeVar("_R")
class DisableOnWriteError(ObjectWrapper):
@staticmethod
def disable_on_exception(tqdm_instance, func: Callable[_P, _R]) -> Callable[_P, _R]: ...
def __init__(self, wrapped, tqdm_instance) -> None: ...
def __eq__(self, other: object) -> bool: ...
class CallbackIOWrapper(ObjectWrapper):
def __init__(self, callback: Callable[[int], object], stream, method: str = ...) -> None: ...
def disp_len(data: str) -> int: ...
def disp_trim(data: str, length: int) -> str: ...

View File