Skip to content

Commit 97fd6c2

Browse files
authored
Bump tqdm to 4.70.* (#16107)
Closes #16099
1 parent 81c8a2d commit 97fd6c2

2 files changed

Lines changed: 102 additions & 17 deletions

File tree

stubs/tqdm/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "4.69.*"
1+
version = "4.70.*"
22
upstream-repository = "https://github.com/tqdm/tqdm"
33
optional-dependencies = ["types-requests", "types-tensorflow"]
44

stubs/tqdm/tqdm/contrib/concurrent.pyi

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
import sys
12
from _typeshed import SupportsWrite
2-
from collections.abc import Callable, Iterable, Mapping
3+
from collections.abc import Callable, Generator, Iterable, Mapping
4+
from contextlib import contextmanager
5+
from multiprocessing.context import BaseContext
36
from typing import Any, TypedDict, TypeVar, overload, type_check_only
47
from typing_extensions import Unpack
58

69
from ..std import tqdm
710

8-
__all__ = ["thread_map", "process_map"]
11+
__all__ = ["thread_map", "process_map", "interpreter_map"]
912

1013
_R = TypeVar("_R")
1114
_T1 = TypeVar("_T1")
@@ -15,12 +18,11 @@ _T4 = TypeVar("_T4")
1518
_T5 = TypeVar("_T5")
1619

1720
@type_check_only
18-
class _TqdmKwargs(TypedDict, total=False):
21+
class _TqdmCommonKwargs(TypedDict, total=False):
1922
# Concurrent-specific parameters
2023
tqdm_class: type[tqdm[object]]
2124
max_workers: int | None
2225
chunksize: int
23-
lock_name: str
2426
# Standard tqdm parameters
2527
desc: str | None
2628
total: float | None
@@ -47,19 +49,42 @@ class _TqdmKwargs(TypedDict, total=False):
4749
colour: str | None
4850
delay: float | None
4951

52+
# TODO: refactor this, when `TypedDict` will support conditional fields
53+
if sys.version_info >= (3, 14):
54+
@type_check_only
55+
class _TqdmKwargs(_TqdmCommonKwargs):
56+
buffersize: int | None
57+
58+
else:
59+
_TqdmKwargs = _TqdmCommonKwargs
60+
61+
@type_check_only
62+
class _TqdmProcessKwargs(_TqdmKwargs):
63+
mp_context: BaseContext | None
64+
max_tasks_per_child: int | None
65+
66+
@type_check_only
67+
class _TqdmThreadKwargs(_TqdmKwargs):
68+
thread_name_prefix: str | None
69+
# Not techically for threading, but just a signature difference:
70+
lock_name: str
71+
72+
@contextmanager
73+
def ensure_lock(tqdm_class: type[tqdm[object]], lock_name: str = "", lock=None) -> Generator[None]: ...
74+
5075
@overload
51-
def thread_map(fn: Callable[[_T1], _R], iter1: Iterable[_T1], **tqdm_kwargs: Unpack[_TqdmKwargs]) -> list[_R]: ...
76+
def thread_map(fn: Callable[[_T1], _R], iter1: Iterable[_T1], **tqdm_kwargs: Unpack[_TqdmThreadKwargs]) -> list[_R]: ...
5277
@overload
5378
def thread_map(
54-
fn: Callable[[_T1, _T2], _R], iter1: Iterable[_T1], iter2: Iterable[_T2], /, **tqdm_kwargs: Unpack[_TqdmKwargs]
79+
fn: Callable[[_T1, _T2], _R], iter1: Iterable[_T1], iter2: Iterable[_T2], /, **tqdm_kwargs: Unpack[_TqdmThreadKwargs]
5580
) -> list[_R]: ...
5681
@overload
5782
def thread_map(
5883
fn: Callable[[_T1, _T2, _T3], _R],
5984
iter1: Iterable[_T1],
6085
iter2: Iterable[_T2],
6186
iter3: Iterable[_T3],
62-
**tqdm_kwargs: Unpack[_TqdmKwargs],
87+
**tqdm_kwargs: Unpack[_TqdmThreadKwargs],
6388
) -> list[_R]: ...
6489
@overload
6590
def thread_map(
@@ -68,7 +93,7 @@ def thread_map(
6893
iter2: Iterable[_T2],
6994
iter3: Iterable[_T3],
7095
iter4: Iterable[_T4],
71-
**tqdm_kwargs: Unpack[_TqdmKwargs],
96+
**tqdm_kwargs: Unpack[_TqdmThreadKwargs],
7297
) -> list[_R]: ...
7398
@overload
7499
def thread_map(
@@ -78,7 +103,7 @@ def thread_map(
78103
iter3: Iterable[_T3],
79104
iter4: Iterable[_T4],
80105
iter5: Iterable[_T5],
81-
**tqdm_kwargs: Unpack[_TqdmKwargs],
106+
**tqdm_kwargs: Unpack[_TqdmThreadKwargs],
82107
) -> list[_R]: ...
83108
@overload
84109
def thread_map(
@@ -90,22 +115,31 @@ def thread_map(
90115
iter5: Iterable[Any],
91116
iter6: Iterable[Any],
92117
*iterables: Iterable[Any],
93-
**tqdm_kwargs: Unpack[_TqdmKwargs],
118+
**tqdm_kwargs: Unpack[_TqdmThreadKwargs],
94119
) -> list[_R]: ...
95120

96121
@overload
97-
def process_map(fn: Callable[[_T1], _R], iter1: Iterable[_T1], **tqdm_kwargs: Unpack[_TqdmKwargs]) -> list[_R]: ...
122+
def process_map(
123+
fn: Callable[[_T1], _R], iter1: Iterable[_T1], *, lock_name: str = "mp_lock", **tqdm_kwargs: Unpack[_TqdmProcessKwargs]
124+
) -> list[_R]: ...
98125
@overload
99126
def process_map(
100-
fn: Callable[[_T1, _T2], _R], iter1: Iterable[_T1], iter2: Iterable[_T2], **tqdm_kwargs: Unpack[_TqdmKwargs]
127+
fn: Callable[[_T1, _T2], _R],
128+
iter1: Iterable[_T1],
129+
iter2: Iterable[_T2],
130+
*,
131+
lock_name: str = "mp_lock",
132+
**tqdm_kwargs: Unpack[_TqdmProcessKwargs],
101133
) -> list[_R]: ...
102134
@overload
103135
def process_map(
104136
fn: Callable[[_T1, _T2, _T3], _R],
105137
iter1: Iterable[_T1],
106138
iter2: Iterable[_T2],
107139
iter3: Iterable[_T3],
108-
**tqdm_kwargs: Unpack[_TqdmKwargs],
140+
*,
141+
lock_name: str = "mp_lock",
142+
**tqdm_kwargs: Unpack[_TqdmProcessKwargs],
109143
) -> list[_R]: ...
110144
@overload
111145
def process_map(
@@ -114,7 +148,9 @@ def process_map(
114148
iter2: Iterable[_T2],
115149
iter3: Iterable[_T3],
116150
iter4: Iterable[_T4],
117-
**tqdm_kwargs: Unpack[_TqdmKwargs],
151+
*,
152+
lock_name: str = "mp_lock",
153+
**tqdm_kwargs: Unpack[_TqdmProcessKwargs],
118154
) -> list[_R]: ...
119155
@overload
120156
def process_map(
@@ -124,7 +160,9 @@ def process_map(
124160
iter3: Iterable[_T3],
125161
iter4: Iterable[_T4],
126162
iter5: Iterable[_T5],
127-
**tqdm_kwargs: Unpack[_TqdmKwargs],
163+
*,
164+
lock_name: str = "mp_lock",
165+
**tqdm_kwargs: Unpack[_TqdmProcessKwargs],
128166
) -> list[_R]: ...
129167
@overload
130168
def process_map(
@@ -136,5 +174,52 @@ def process_map(
136174
iter5: Iterable[Any],
137175
iter6: Iterable[Any],
138176
*iterables: Iterable[Any],
139-
**tqdm_kwargs: Unpack[_TqdmKwargs],
177+
lock_name: str = "mp_lock",
178+
**tqdm_kwargs: Unpack[_TqdmProcessKwargs],
179+
) -> list[_R]: ...
180+
181+
@overload
182+
def interpreter_map(fn: Callable[[_T1], _R], iter1: Iterable[_T1], **tqdm_kwargs: Unpack[_TqdmThreadKwargs]) -> list[_R]: ...
183+
@overload
184+
def interpreter_map(
185+
fn: Callable[[_T1, _T2], _R], iter1: Iterable[_T1], iter2: Iterable[_T2], /, **tqdm_kwargs: Unpack[_TqdmThreadKwargs]
186+
) -> list[_R]: ...
187+
@overload
188+
def interpreter_map(
189+
fn: Callable[[_T1, _T2, _T3], _R],
190+
iter1: Iterable[_T1],
191+
iter2: Iterable[_T2],
192+
iter3: Iterable[_T3],
193+
**tqdm_kwargs: Unpack[_TqdmThreadKwargs],
194+
) -> list[_R]: ...
195+
@overload
196+
def interpreter_map(
197+
fn: Callable[[_T1, _T2, _T3, _T4], _R],
198+
iter1: Iterable[_T1],
199+
iter2: Iterable[_T2],
200+
iter3: Iterable[_T3],
201+
iter4: Iterable[_T4],
202+
**tqdm_kwargs: Unpack[_TqdmThreadKwargs],
203+
) -> list[_R]: ...
204+
@overload
205+
def interpreter_map(
206+
fn: Callable[[_T1, _T2, _T3, _T4, _T5], _R],
207+
iter1: Iterable[_T1],
208+
iter2: Iterable[_T2],
209+
iter3: Iterable[_T3],
210+
iter4: Iterable[_T4],
211+
iter5: Iterable[_T5],
212+
**tqdm_kwargs: Unpack[_TqdmThreadKwargs],
213+
) -> list[_R]: ...
214+
@overload
215+
def interpreter_map(
216+
fn: Callable[..., _R],
217+
iter1: Iterable[Any],
218+
iter2: Iterable[Any],
219+
iter3: Iterable[Any],
220+
iter4: Iterable[Any],
221+
iter5: Iterable[Any],
222+
iter6: Iterable[Any],
223+
*iterables: Iterable[Any],
224+
**tqdm_kwargs: Unpack[_TqdmThreadKwargs],
140225
) -> list[_R]: ...

0 commit comments

Comments
 (0)