dycw-utilities 0.126.0__py3-none-any.whl → 0.126.2__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.
- {dycw_utilities-0.126.0.dist-info → dycw_utilities-0.126.2.dist-info}/METADATA +2 -2
- {dycw_utilities-0.126.0.dist-info → dycw_utilities-0.126.2.dist-info}/RECORD +7 -7
- utilities/__init__.py +1 -1
- utilities/errors.py +4 -0
- utilities/redis.py +12 -22
- {dycw_utilities-0.126.0.dist-info → dycw_utilities-0.126.2.dist-info}/WHEEL +0 -0
- {dycw_utilities-0.126.0.dist-info → dycw_utilities-0.126.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: dycw-utilities
|
3
|
-
Version: 0.126.
|
3
|
+
Version: 0.126.2
|
4
4
|
Author-email: Derek Wan <d.wan@icloud.com>
|
5
5
|
License-File: LICENSE
|
6
6
|
Requires-Python: >=3.12
|
@@ -174,7 +174,7 @@ Requires-Dist: scipy<1.16,>=1.15.3; extra == 'zzz-test-scipy'
|
|
174
174
|
Provides-Extra: zzz-test-sentinel
|
175
175
|
Provides-Extra: zzz-test-shelve
|
176
176
|
Provides-Extra: zzz-test-slack-sdk
|
177
|
-
Requires-Dist: aiohttp<3.12.
|
177
|
+
Requires-Dist: aiohttp<3.12.7,>=3.12.6; extra == 'zzz-test-slack-sdk'
|
178
178
|
Requires-Dist: slack-sdk<3.36,>=3.35.0; extra == 'zzz-test-slack-sdk'
|
179
179
|
Provides-Extra: zzz-test-socket
|
180
180
|
Provides-Extra: zzz-test-sqlalchemy
|
@@ -1,4 +1,4 @@
|
|
1
|
-
utilities/__init__.py,sha256=
|
1
|
+
utilities/__init__.py,sha256=oG_3_PTYR4RRwJNt7YUNCU570YlGyZIR_E1X-yfdGqY,60
|
2
2
|
utilities/altair.py,sha256=Gpja-flOo-Db0PIPJLJsgzAlXWoKUjPU1qY-DQ829ek,9156
|
3
3
|
utilities/asyncio.py,sha256=K5Kj7rsM0nA17-b7d7mrNgPR1U_NbkfQmTruq5LBLRA,51778
|
4
4
|
utilities/atomicwrites.py,sha256=geFjn9Pwn-tTrtoGjDDxWli9NqbYfy3gGL6ZBctiqSo,5393
|
@@ -13,7 +13,7 @@ utilities/cvxpy.py,sha256=Rv1-fD-XYerosCavRF8Pohop2DBkU3AlFaGTfD8AEAA,13776
|
|
13
13
|
utilities/dataclasses.py,sha256=iiC1wpGXWhaocIikzwBt8bbLWyImoUlOlcDZJGejaIg,33011
|
14
14
|
utilities/datetime.py,sha256=uYoaOi_C1YtNXGfTN9xlTrW62Re2b1_4Skuv14_MeYQ,38985
|
15
15
|
utilities/enum.py,sha256=HoRwVCWzsnH0vpO9ZEcAAIZLMv0Sn2vJxxA4sYMQgDs,5793
|
16
|
-
utilities/errors.py,sha256=
|
16
|
+
utilities/errors.py,sha256=nC7ZYtxxDBMfrTHtT_MByBfup_wfGQFRo3eDt-0ZPe8,1045
|
17
17
|
utilities/eventkit.py,sha256=6M5Xu1SzN-juk9PqBHwy5dS-ta7T0qA6SMpDsakOJ0E,13039
|
18
18
|
utilities/fastapi.py,sha256=LG1-Q8RDi7wsyVN6v74qptPYX8WGXPkFOQFniMvtzjc,2439
|
19
19
|
utilities/fpdf2.py,sha256=y1NGXR5chWqLXWpewGV3hlRGMr_5yV1lVRkPBhPEgJI,1843
|
@@ -60,7 +60,7 @@ utilities/pytest_regressions.py,sha256=-SVT9647Dg6-JcdsiaDKXe3NdOmmrvGevLKWwGjxq
|
|
60
60
|
utilities/python_dotenv.py,sha256=iWcnpXbH7S6RoXHiLlGgyuH6udCupAcPd_gQ0eAenQ0,3190
|
61
61
|
utilities/random.py,sha256=lYdjgxB7GCfU_fwFVl5U-BIM_HV3q6_urL9byjrwDM8,4157
|
62
62
|
utilities/re.py,sha256=5J4d8VwIPFVrX2Eb8zfoxImDv7IwiN_U7mJ07wR2Wvs,3958
|
63
|
-
utilities/redis.py,sha256=
|
63
|
+
utilities/redis.py,sha256=DTkNR_caxlx06rH-ugcClroErKsu6NDGMYGIgEng05c,32570
|
64
64
|
utilities/reprlib.py,sha256=Re9bk3n-kC__9DxQmRlevqFA86pE6TtVfWjUgpbVOv0,1849
|
65
65
|
utilities/rich.py,sha256=t50MwwVBsoOLxzmeVFSVpjno4OW6Ufum32skXbV8-Bs,1911
|
66
66
|
utilities/scipy.py,sha256=X6ROnHwiUhAmPhM0jkfEh0-Fd9iRvwiqtCQMOLmOQF8,945
|
@@ -90,7 +90,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
|
|
90
90
|
utilities/whenever.py,sha256=jS31ZAY5OMxFxLja_Yo5Fidi87Pd-GoVZ7Vi_teqVDA,16743
|
91
91
|
utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
|
92
92
|
utilities/zoneinfo.py,sha256=-5j7IQ9nb7gR43rdgA7ms05im-XuqhAk9EJnQBXxCoQ,1874
|
93
|
-
dycw_utilities-0.126.
|
94
|
-
dycw_utilities-0.126.
|
95
|
-
dycw_utilities-0.126.
|
96
|
-
dycw_utilities-0.126.
|
93
|
+
dycw_utilities-0.126.2.dist-info/METADATA,sha256=0QZHN43mRwTBwhoYhygzaYieXnLM6qsG4ANxaqYs4Ls,12851
|
94
|
+
dycw_utilities-0.126.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
95
|
+
dycw_utilities-0.126.2.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
|
96
|
+
dycw_utilities-0.126.2.dist-info/RECORD,,
|
utilities/__init__.py
CHANGED
utilities/errors.py
CHANGED
@@ -24,6 +24,10 @@ class ImpossibleCaseError(Exception):
|
|
24
24
|
def repr_error(error: MaybeType[BaseException], /) -> str:
|
25
25
|
"""Get a string representation of an error."""
|
26
26
|
match error:
|
27
|
+
case ExceptionGroup() as group:
|
28
|
+
descs = list(map(repr_error, group.exceptions))
|
29
|
+
joined = ", ".join(descs)
|
30
|
+
return f"{group.__class__.__name__}({joined})"
|
27
31
|
case BaseException() as error_obj:
|
28
32
|
return f"{error_obj.__class__.__name__}({error_obj})"
|
29
33
|
case type() as error_cls:
|
utilities/redis.py
CHANGED
@@ -657,7 +657,7 @@ class PublisherError(Exception):
|
|
657
657
|
|
658
658
|
|
659
659
|
@dataclass(kw_only=True)
|
660
|
-
class PublishService(Looper[tuple[str, _T]]):
|
660
|
+
class PublishService(Looper[tuple[str, bytes | str | _T]]):
|
661
661
|
"""Service to publish items to Redis."""
|
662
662
|
|
663
663
|
# base
|
@@ -677,7 +677,7 @@ class PublishService(Looper[tuple[str, _T]]):
|
|
677
677
|
_ = await publish(
|
678
678
|
self.redis,
|
679
679
|
channel,
|
680
|
-
|
680
|
+
data,
|
681
681
|
serializer=self.serializer,
|
682
682
|
timeout=self.publish_timeout,
|
683
683
|
)
|
@@ -695,7 +695,7 @@ _SUBSCRIBE_SLEEP: Duration = MILLISECOND
|
|
695
695
|
def subscribe(
|
696
696
|
redis: Redis,
|
697
697
|
channels: MaybeIterable[str],
|
698
|
-
queue: Queue[
|
698
|
+
queue: Queue[_RedisMessage],
|
699
699
|
/,
|
700
700
|
*,
|
701
701
|
timeout: Duration | None = _SUBSCRIBE_TIMEOUT,
|
@@ -742,7 +742,7 @@ def subscribe(
|
|
742
742
|
async def subscribe(
|
743
743
|
redis: Redis,
|
744
744
|
channels: MaybeIterable[str],
|
745
|
-
queue: Queue[
|
745
|
+
queue: Queue[_RedisMessage] | Queue[bytes] | Queue[_T],
|
746
746
|
/,
|
747
747
|
*,
|
748
748
|
timeout: Duration | None = _SUBSCRIBE_TIMEOUT,
|
@@ -758,12 +758,12 @@ async def subscribe(
|
|
758
758
|
transform = cast("Any", itemgetter("data"))
|
759
759
|
case "text":
|
760
760
|
|
761
|
-
def transform(message:
|
761
|
+
def transform(message: _RedisMessage, /) -> str: # pyright: ignore[reportRedeclaration]
|
762
762
|
return message["data"].decode()
|
763
763
|
|
764
764
|
case Callable() as deserialize:
|
765
765
|
|
766
|
-
def transform(message:
|
766
|
+
def transform(message: _RedisMessage, /) -> _T:
|
767
767
|
return deserialize(message["data"])
|
768
768
|
|
769
769
|
case _ as never:
|
@@ -783,7 +783,7 @@ async def subscribe(
|
|
783
783
|
async def _subscribe_core(
|
784
784
|
redis: Redis,
|
785
785
|
channels: MaybeIterable[str],
|
786
|
-
transform: Callable[[
|
786
|
+
transform: Callable[[_RedisMessage], Any],
|
787
787
|
queue: Queue[Any],
|
788
788
|
/,
|
789
789
|
*,
|
@@ -795,14 +795,11 @@ async def _subscribe_core(
|
|
795
795
|
)
|
796
796
|
sleep_use = datetime_duration_to_float(sleep) # skipif-ci-and-not-linux
|
797
797
|
is_subscribe_message = partial( # skipif-ci-and-not-linux
|
798
|
-
|
798
|
+
_is_message, channels={c.encode() for c in channels}
|
799
799
|
)
|
800
800
|
async with yield_pubsub(redis, channels) as pubsub: # skipif-ci-and-not-linux
|
801
801
|
while True:
|
802
|
-
message =
|
803
|
-
"_RedisMessageSubscribe | _RedisMessageUnsubscribe | None",
|
804
|
-
await pubsub.get_message(timeout=timeout_use),
|
805
|
-
)
|
802
|
+
message = await pubsub.get_message(timeout=timeout_use)
|
806
803
|
if is_subscribe_message(message):
|
807
804
|
if isinstance(queue, EnhancedQueue):
|
808
805
|
queue.put_right_nowait(transform(message))
|
@@ -812,9 +809,9 @@ async def _subscribe_core(
|
|
812
809
|
await asyncio.sleep(sleep_use)
|
813
810
|
|
814
811
|
|
815
|
-
def
|
812
|
+
def _is_message(
|
816
813
|
message: Any, /, *, channels: Collection[bytes]
|
817
|
-
) -> TypeGuard[
|
814
|
+
) -> TypeGuard[_RedisMessage]:
|
818
815
|
return (
|
819
816
|
isinstance(message, Mapping)
|
820
817
|
and ("type" in message)
|
@@ -828,20 +825,13 @@ def _is_subscribe_message(
|
|
828
825
|
)
|
829
826
|
|
830
827
|
|
831
|
-
class
|
828
|
+
class _RedisMessage(TypedDict):
|
832
829
|
type: Literal["subscribe", "psubscribe", "message", "pmessage"]
|
833
830
|
pattern: str | None
|
834
831
|
channel: bytes
|
835
832
|
data: bytes
|
836
833
|
|
837
834
|
|
838
|
-
class _RedisMessageUnsubscribe(TypedDict):
|
839
|
-
type: Literal["unsubscribe", "punsubscribe"]
|
840
|
-
pattern: str | None
|
841
|
-
channel: bytes
|
842
|
-
data: int
|
843
|
-
|
844
|
-
|
845
835
|
##
|
846
836
|
|
847
837
|
|
File without changes
|
File without changes
|