dycw-utilities 0.114.7__py3-none-any.whl → 0.115.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dycw-utilities
3
- Version: 0.114.7
3
+ Version: 0.115.1
4
4
  Author-email: Derek Wan <d.wan@icloud.com>
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.12
@@ -1,7 +1,7 @@
1
- utilities/__init__.py,sha256=-ANGg4AV-lK1zx4OPl8Bt3ZaulOvLmPCM_JsK1PAoVg,60
1
+ utilities/__init__.py,sha256=TbTtbGuM9AadB_WkxBUd94oWTm59iHPdjdluFVXZ-HI,60
2
2
  utilities/altair.py,sha256=Gpja-flOo-Db0PIPJLJsgzAlXWoKUjPU1qY-DQ829ek,9156
3
3
  utilities/astor.py,sha256=xuDUkjq0-b6fhtwjhbnebzbqQZAjMSHR1IIS5uOodVg,777
4
- utilities/asyncio.py,sha256=zz8W_35vp3u7N4rRahr82HmBnq6uXWgJe8XW8KgXh6w,21507
4
+ utilities/asyncio.py,sha256=rDsYSQUhl2YZQKtkbeCNK4Mrbh5heVaqWLvLn2ppMJg,21534
5
5
  utilities/atomicwrites.py,sha256=geFjn9Pwn-tTrtoGjDDxWli9NqbYfy3gGL6ZBctiqSo,5393
6
6
  utilities/atools.py,sha256=IYMuFSFGSKyuQmqD6v5IUtDlz8PPw0Sr87Cub_gRU3M,1168
7
7
  utilities/cachetools.py,sha256=C1zqOg7BYz0IfQFK8e3qaDDgEZxDpo47F15RTfJM37Q,2910
@@ -58,7 +58,7 @@ utilities/pytest_regressions.py,sha256=-SVT9647Dg6-JcdsiaDKXe3NdOmmrvGevLKWwGjxq
58
58
  utilities/python_dotenv.py,sha256=iWcnpXbH7S6RoXHiLlGgyuH6udCupAcPd_gQ0eAenQ0,3190
59
59
  utilities/random.py,sha256=lYdjgxB7GCfU_fwFVl5U-BIM_HV3q6_urL9byjrwDM8,4157
60
60
  utilities/re.py,sha256=5J4d8VwIPFVrX2Eb8zfoxImDv7IwiN_U7mJ07wR2Wvs,3958
61
- utilities/redis.py,sha256=Zf9MVDgwZa3NeZ8XM9MdKgtUXMidfh_avnsb4J_8QOQ,26675
61
+ utilities/redis.py,sha256=0LAmbQFkwbJ3w6teTqGw1fNCSs1tDivL3DVAqob0S5c,26732
62
62
  utilities/reprlib.py,sha256=Re9bk3n-kC__9DxQmRlevqFA86pE6TtVfWjUgpbVOv0,1849
63
63
  utilities/rich.py,sha256=t50MwwVBsoOLxzmeVFSVpjno4OW6Ufum32skXbV8-Bs,1911
64
64
  utilities/scipy.py,sha256=X6ROnHwiUhAmPhM0jkfEh0-Fd9iRvwiqtCQMOLmOQF8,945
@@ -87,7 +87,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
87
87
  utilities/whenever.py,sha256=iLRP_-8CZtBpHKbGZGu-kjSMg1ZubJ-VSmgSy7Eudxw,17787
88
88
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
89
89
  utilities/zoneinfo.py,sha256=-Xm57PMMwDTYpxJdkiJG13wnbwK--I7XItBh5WVhD-o,1874
90
- dycw_utilities-0.114.7.dist-info/METADATA,sha256=jnelg2snp4k8jzWjEF-sP7-Ll4wStToFmbTz07nqgLs,12943
91
- dycw_utilities-0.114.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
92
- dycw_utilities-0.114.7.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
93
- dycw_utilities-0.114.7.dist-info/RECORD,,
90
+ dycw_utilities-0.115.1.dist-info/METADATA,sha256=Bqi_67m9vtvYTiPadk63p01uSHmZlqyxM7_6YEuoo3A,12943
91
+ dycw_utilities-0.115.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
92
+ dycw_utilities-0.115.1.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
93
+ dycw_utilities-0.115.1.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.114.7"
3
+ __version__ = "0.115.1"
utilities/asyncio.py CHANGED
@@ -45,6 +45,7 @@ from utilities.errors import ImpossibleCaseError
45
45
  from utilities.functions import ensure_int, ensure_not_none, get_class_name
46
46
  from utilities.sentinel import Sentinel, sentinel
47
47
  from utilities.types import (
48
+ Coroutine1,
48
49
  MaybeCallableEvent,
49
50
  MaybeType,
50
51
  THashable,
@@ -344,10 +345,10 @@ class InfiniteLooper(ABC, Generic[THashable]):
344
345
 
345
346
  async def __call__(self) -> None:
346
347
  """Create a coroutine to run the looper."""
347
- loopers = list(self._yield_loopers())
348
- if len(loopers) == 0:
348
+ coroutines = list(self._yield_coroutines())
349
+ if len(coroutines) == 0:
349
350
  return await self._run_looper()
350
- return await self._run_multiple_loopers(*loopers)
351
+ return await self._run_looper_with_coroutines(*coroutines)
351
352
 
352
353
  async def _run_looper(self) -> None:
353
354
  """Run the looper by itself."""
@@ -378,14 +379,14 @@ class InfiniteLooper(ABC, Generic[THashable]):
378
379
  self._error_upon_core(error)
379
380
  await sleep_dur(duration=self.sleep_restart)
380
381
 
381
- async def _run_multiple_loopers(self, *loopers: InfiniteLooper) -> None:
382
+ async def _run_looper_with_coroutines(self, *coroutines: Coroutine1) -> None:
382
383
  """Run multiple loopers."""
383
384
  while True:
384
385
  self._reset_events()
385
386
  try:
386
387
  async with TaskGroup() as tg:
387
388
  _ = tg.create_task(self._run_looper())
388
- _ = [tg.create_task(looper()) for looper in loopers]
389
+ _ = list(map(tg.create_task, coroutines))
389
390
  except Exception as error: # noqa: BLE001
390
391
  self._error_upon_core(error) # pragma: no cover
391
392
  await sleep_dur(duration=self.sleep_restart) # pragma: no cover
@@ -436,16 +437,16 @@ class InfiniteLooper(ABC, Generic[THashable]):
436
437
  raise InfiniteLooperError(event=event) from None
437
438
  event_obj.set()
438
439
 
440
+ def _yield_coroutines(self) -> Iterator[Coroutine1[None]]:
441
+ """Yield any other coroutines which must also be run."""
442
+ yield from []
443
+
439
444
  def _yield_events_and_exceptions(
440
445
  self,
441
446
  ) -> Iterator[tuple[THashable, MaybeType[BaseException]]]:
442
447
  """Yield the events & exceptions."""
443
448
  yield from []
444
449
 
445
- def _yield_loopers(self) -> Iterator[InfiniteLooper]:
446
- """Yield any other infinite loopers which must also be run."""
447
- yield from []
448
-
449
450
 
450
451
  @dataclass(kw_only=True, slots=True)
451
452
  class InfiniteLooperError(Exception):
utilities/redis.py CHANGED
@@ -648,7 +648,7 @@ _SUBSCRIBE_SLEEP: Duration = MILLISECOND
648
648
 
649
649
 
650
650
  @overload
651
- async def subscribe(
651
+ def subscribe(
652
652
  pubsub: PubSub,
653
653
  channels: MaybeIterable[str],
654
654
  /,
@@ -658,7 +658,7 @@ async def subscribe(
658
658
  sleep: Duration = _SUBSCRIBE_SLEEP,
659
659
  ) -> AsyncIterator[_T]: ...
660
660
  @overload
661
- async def subscribe(
661
+ def subscribe(
662
662
  pubsub: PubSub,
663
663
  channels: MaybeIterable[str],
664
664
  /,
@@ -667,7 +667,7 @@ async def subscribe(
667
667
  timeout: Duration | None = _SUBSCRIBE_TIMEOUT,
668
668
  sleep: Duration = _SUBSCRIBE_SLEEP,
669
669
  ) -> AsyncIterator[bytes]: ...
670
- async def subscribe(
670
+ async def subscribe( # pyright: ignore[reportInconsistentOverload]
671
671
  pubsub: PubSub,
672
672
  channels: MaybeIterable[str],
673
673
  /,
@@ -675,7 +675,7 @@ async def subscribe(
675
675
  deserializer: Callable[[bytes], _T] | None = None,
676
676
  timeout: Duration | None = _SUBSCRIBE_TIMEOUT,
677
677
  sleep: Duration = _SUBSCRIBE_SLEEP,
678
- ) -> AsyncIterator[Any]:
678
+ ) -> AsyncIterator[_T] | AsyncIterator[bytes]:
679
679
  """Subscribe to the data of a given channel(s)."""
680
680
  channels = list(always_iterable(channels)) # skipif-ci-and-not-linux
681
681
  messages = subscribe_messages( # skipif-ci-and-not-linux