python-iterutils 0.0.7__py3-none-any.whl → 0.0.7.1__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 +18 -13
- {python_iterutils-0.0.7.dist-info → python_iterutils-0.0.7.1.dist-info}/METADATA +1 -1
- python_iterutils-0.0.7.1.dist-info/RECORD +7 -0
- python_iterutils-0.0.7.dist-info/RECORD +0 -7
- {python_iterutils-0.0.7.dist-info → python_iterutils-0.0.7.1.dist-info}/LICENSE +0 -0
- {python_iterutils-0.0.7.dist-info → python_iterutils-0.0.7.1.dist-info}/WHEEL +0 -0
iterutils/__init__.py
CHANGED
|
@@ -9,13 +9,14 @@ __all__ = [
|
|
|
9
9
|
"Yield", "YieldFrom",
|
|
10
10
|
]
|
|
11
11
|
|
|
12
|
+
from dataclasses import dataclass
|
|
12
13
|
from abc import ABC, abstractmethod
|
|
13
14
|
from asyncio import to_thread
|
|
14
15
|
from collections.abc import (
|
|
15
|
-
AsyncIterable, AsyncIterator,
|
|
16
|
+
AsyncIterable, AsyncIterator, Callable, Generator, Iterable, Iterator,
|
|
16
17
|
)
|
|
17
18
|
from inspect import isawaitable
|
|
18
|
-
from typing import overload, Any, Literal,
|
|
19
|
+
from typing import overload, Any, Literal, TypeVar
|
|
19
20
|
|
|
20
21
|
from asynctools import async_zip, ensure_async, ensure_aiter
|
|
21
22
|
|
|
@@ -23,23 +24,23 @@ from asynctools import async_zip, ensure_async, ensure_aiter
|
|
|
23
24
|
T = TypeVar("T")
|
|
24
25
|
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
@dataclass(slots=True, frozen=True)
|
|
28
|
+
class YieldBase(ABC):
|
|
29
|
+
value: Any
|
|
30
|
+
identity: bool = False
|
|
31
|
+
try_call_me: bool = True
|
|
32
|
+
|
|
28
33
|
@property
|
|
29
34
|
@abstractmethod
|
|
30
35
|
def yield_type(self, /) -> int:
|
|
31
36
|
...
|
|
32
37
|
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
value: Any
|
|
37
|
-
identity: bool = False
|
|
38
|
-
try_call_me: bool = True
|
|
39
|
-
yield_type = 1 # type: ignore
|
|
39
|
+
class Yield(YieldBase):
|
|
40
|
+
yield_type = 1
|
|
40
41
|
|
|
41
42
|
|
|
42
|
-
class YieldFrom(
|
|
43
|
+
class YieldFrom(YieldBase):
|
|
43
44
|
yield_type = 2
|
|
44
45
|
|
|
45
46
|
|
|
@@ -309,8 +310,10 @@ def run_gen_step_iter(
|
|
|
309
310
|
identity = False
|
|
310
311
|
try_call_me = True
|
|
311
312
|
if isinstance(ret, YieldBase):
|
|
313
|
+
identity = ret.identity
|
|
314
|
+
try_call_me = ret.try_call_me
|
|
312
315
|
yield_type = ret.yield_type
|
|
313
|
-
ret
|
|
316
|
+
ret = ret.value
|
|
314
317
|
if not identity:
|
|
315
318
|
if try_call_me and callable(ret):
|
|
316
319
|
ret = ret()
|
|
@@ -364,8 +367,10 @@ def run_gen_step_iter(
|
|
|
364
367
|
identity = False
|
|
365
368
|
try_call_me = True
|
|
366
369
|
if isinstance(ret, YieldBase):
|
|
370
|
+
identity = ret.identity
|
|
371
|
+
try_call_me = ret.try_call_me
|
|
367
372
|
yield_type = ret.yield_type
|
|
368
|
-
ret
|
|
373
|
+
ret = ret.value
|
|
369
374
|
if not identity and try_call_me and callable(ret):
|
|
370
375
|
ret = ret()
|
|
371
376
|
return yield_type, ret
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
2
|
+
iterutils/__init__.py,sha256=d1nN35bvpA0SJTgYFKmWtt6cofF6p4yg1E_uhKyyzFw,12101
|
|
3
|
+
iterutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
python_iterutils-0.0.7.1.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
5
|
+
python_iterutils-0.0.7.1.dist-info/METADATA,sha256=Fv-Zi3_OkM31ZPHTO0JBLmACgs7rFEqFJLchFJUWErU,1384
|
|
6
|
+
python_iterutils-0.0.7.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
7
|
+
python_iterutils-0.0.7.1.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
2
|
-
iterutils/__init__.py,sha256=_oyqibVk_HLON3Kn8EGkmEggNxB9XZnPiNMQrO9z5u4,11992
|
|
3
|
-
iterutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
python_iterutils-0.0.7.dist-info/LICENSE,sha256=o5242_N2TgDsWwFhPn7yr8YJNF7XsJM5NxUMtcT97bc,1100
|
|
5
|
-
python_iterutils-0.0.7.dist-info/METADATA,sha256=9lmNIU8a1YVGh3cO1TwUqh0sdXh__fjd3sSkha3BT0c,1382
|
|
6
|
-
python_iterutils-0.0.7.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
7
|
-
python_iterutils-0.0.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|