python-iterutils 0.0.4.3__py3-none-any.whl → 0.0.4.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iterutils/__init__.py +12 -25
- {python_iterutils-0.0.4.3.dist-info → python_iterutils-0.0.4.5.dist-info}/METADATA +1 -1
- python_iterutils-0.0.4.5.dist-info/RECORD +7 -0
- python_iterutils-0.0.4.3.dist-info/RECORD +0 -7
- {python_iterutils-0.0.4.3.dist-info → python_iterutils-0.0.4.5.dist-info}/LICENSE +0 -0
- {python_iterutils-0.0.4.3.dist-info → python_iterutils-0.0.4.5.dist-info}/WHEEL +0 -0
iterutils/__init__.py
CHANGED
|
@@ -13,7 +13,7 @@ from collections.abc import (
|
|
|
13
13
|
AsyncIterable, AsyncIterator, Awaitable, Callable, Generator, Iterable, Iterator,
|
|
14
14
|
)
|
|
15
15
|
from inspect import isawaitable
|
|
16
|
-
from typing import
|
|
16
|
+
from typing import Any, TypeVar
|
|
17
17
|
|
|
18
18
|
from asynctools import async_zip, ensure_async, ensure_aiter
|
|
19
19
|
|
|
@@ -167,31 +167,13 @@ def cut_iter(
|
|
|
167
167
|
yield stop, stop - start
|
|
168
168
|
|
|
169
169
|
|
|
170
|
-
@overload
|
|
171
170
|
def run_gen_step(
|
|
172
|
-
gen_step: Generator[
|
|
173
|
-
*,
|
|
174
|
-
async_: Literal[False] = False,
|
|
175
|
-
threaded: bool = False,
|
|
176
|
-
as_iter: bool = False,
|
|
177
|
-
) -> T:
|
|
178
|
-
...
|
|
179
|
-
@overload
|
|
180
|
-
def run_gen_step(
|
|
181
|
-
gen_step: Generator[Callable, Any, T] | Callable[[], Generator[Callable, Any, T]],
|
|
182
|
-
*,
|
|
183
|
-
async_: Literal[True],
|
|
184
|
-
threaded: bool = False,
|
|
185
|
-
as_iter: bool = False,
|
|
186
|
-
) -> Awaitable[T]:
|
|
187
|
-
...
|
|
188
|
-
def run_gen_step(
|
|
189
|
-
gen_step: Generator[Callable, Any, T] | Callable[[], Generator[Callable, Any, T]],
|
|
171
|
+
gen_step: Generator[Any, Any, T] | Callable[[], Generator[Any, Any, T]],
|
|
190
172
|
*,
|
|
191
173
|
async_: bool = False,
|
|
192
174
|
threaded: bool = False,
|
|
193
175
|
as_iter: bool = False,
|
|
194
|
-
) -> T
|
|
176
|
+
) -> T:
|
|
195
177
|
if callable(gen_step):
|
|
196
178
|
gen = gen_step()
|
|
197
179
|
close = gen.close
|
|
@@ -209,9 +191,14 @@ def run_gen_step(
|
|
|
209
191
|
func = send(None)
|
|
210
192
|
while True:
|
|
211
193
|
try:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
194
|
+
if isawaitable(func):
|
|
195
|
+
ret = await func
|
|
196
|
+
elif callable(func):
|
|
197
|
+
ret = func()
|
|
198
|
+
if isawaitable(ret):
|
|
199
|
+
ret = await ret
|
|
200
|
+
else:
|
|
201
|
+
ret = func
|
|
215
202
|
except BaseException as e:
|
|
216
203
|
if threaded:
|
|
217
204
|
func = await to_thread(throw, e)
|
|
@@ -251,7 +238,7 @@ def run_gen_step(
|
|
|
251
238
|
func = send(None)
|
|
252
239
|
while True:
|
|
253
240
|
try:
|
|
254
|
-
ret = func()
|
|
241
|
+
ret = func() if callable(func) else ret
|
|
255
242
|
except BaseException as e:
|
|
256
243
|
func = throw(e)
|
|
257
244
|
else:
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
2
|
+
iterutils/__init__.py,sha256=aUoT5_AkcRUYDM5M9WHckr_URTA01jKhbPDcufH90Ko,7381
|
|
3
|
+
iterutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
python_iterutils-0.0.4.5.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
5
|
+
python_iterutils-0.0.4.5.dist-info/METADATA,sha256=feKv9AWPu1xSoVXmPjJN86CY3xUzMLjaUEPbPpW79LY,1384
|
|
6
|
+
python_iterutils-0.0.4.5.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
7
|
+
python_iterutils-0.0.4.5.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
2
|
-
iterutils/__init__.py,sha256=28I7UIPitCAj72fQsdq__WDN6F2-jsMrJGC-BShgWTQ,7651
|
|
3
|
-
iterutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
python_iterutils-0.0.4.3.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
5
|
-
python_iterutils-0.0.4.3.dist-info/METADATA,sha256=lfVGyCq0C0HyQf2wkjznLunZmm3vJedXu69VSTOH_bE,1384
|
|
6
|
-
python_iterutils-0.0.4.3.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
7
|
-
python_iterutils-0.0.4.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|