python-iterutils 0.0.4.3__tar.gz → 0.0.4.5__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-iterutils
3
- Version: 0.0.4.3
3
+ Version: 0.0.4.5
4
4
  Summary: Python another itertools.
5
5
  Home-page: https://github.com/ChenyangGao/web-mount-packs/tree/main/python-module/python-iterutils
6
6
  License: MIT
@@ -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 overload, Any, Literal, TypeVar
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[Callable, Any, T] | Callable[[], Generator[Callable, Any, T]],
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 | Awaitable[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
- ret = func()
213
- if isawaitable(ret):
214
- ret = await ret
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:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-iterutils"
3
- version = "0.0.4.3"
3
+ version = "0.0.4.5"
4
4
  description = "Python another itertools."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"