dycw-utilities 0.122.0__py3-none-any.whl → 0.122.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.122.0
3
+ Version: 0.122.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=V19RNamTpOs4KxZ_wh7w8SsT-d-C24iIQHK07Pu3opA,60
1
+ utilities/__init__.py,sha256=HQ1CqsUZ8X8-X0sFT3wvjjj0NMYqAnzvjRBDmvWB2xU,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=sVCGCGl5vGo1MztLcd46DiuWBR6XQW1CsGDyDdaevYg,22766
4
+ utilities/asyncio.py,sha256=cjXpSezv95ZG3t-D9sXLOn6BGBj7w-Wf4udvE5gU4vU,23508
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
@@ -88,7 +88,7 @@ utilities/warnings.py,sha256=un1LvHv70PU-LLv8RxPVmugTzDJkkGXRMZTE2-fTQHw,1771
88
88
  utilities/whenever.py,sha256=jS31ZAY5OMxFxLja_Yo5Fidi87Pd-GoVZ7Vi_teqVDA,16743
89
89
  utilities/zipfile.py,sha256=24lQc9ATcJxHXBPc_tBDiJk48pWyRrlxO2fIsFxU0A8,699
90
90
  utilities/zoneinfo.py,sha256=-5j7IQ9nb7gR43rdgA7ms05im-XuqhAk9EJnQBXxCoQ,1874
91
- dycw_utilities-0.122.0.dist-info/METADATA,sha256=VUsd4omUw1y-str8uasKFbLZUMA2Sr3HpSaq8f8coh0,12943
92
- dycw_utilities-0.122.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
- dycw_utilities-0.122.0.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
- dycw_utilities-0.122.0.dist-info/RECORD,,
91
+ dycw_utilities-0.122.1.dist-info/METADATA,sha256=9QN9Ulm7O-TsU1Zg2xrl5ylNadZMkHMp9ktRVFxpFwQ,12943
92
+ dycw_utilities-0.122.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
93
+ dycw_utilities-0.122.1.dist-info/licenses/LICENSE,sha256=gppZp16M6nSVpBbUBrNL6JuYfvKwZiKgV7XoKKsHzqo,1066
94
+ dycw_utilities-0.122.1.dist-info/RECORD,,
utilities/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  from __future__ import annotations
2
2
 
3
- __version__ = "0.122.0"
3
+ __version__ = "0.122.1"
utilities/asyncio.py CHANGED
@@ -19,6 +19,7 @@ from asyncio import (
19
19
  )
20
20
  from collections.abc import Callable, Hashable, Iterable, Iterator, Mapping
21
21
  from contextlib import (
22
+ AbstractAsyncContextManager,
22
23
  AsyncExitStack,
23
24
  _AsyncGeneratorContextManager,
24
25
  asynccontextmanager,
@@ -85,6 +86,8 @@ class EnhancedTaskGroup(TaskGroup):
85
86
  _semaphore: Semaphore | None
86
87
  _timeout: Duration | None
87
88
  _error: type[Exception]
89
+ _stack: AsyncExitStack
90
+ _stack_entered: bool
88
91
  _timeout_cm: _AsyncGeneratorContextManager[None] | None
89
92
 
90
93
  @override
@@ -99,8 +102,25 @@ class EnhancedTaskGroup(TaskGroup):
99
102
  self._semaphore = None if max_tasks is None else Semaphore(max_tasks)
100
103
  self._timeout = timeout
101
104
  self._error = error
105
+ self._stack = AsyncExitStack()
106
+ self._stack_entered = False # TOOD: no need
102
107
  self._timeout_cm = None
103
108
 
109
+ @override
110
+ async def __aenter__(self) -> Self:
111
+ _ = await self._stack.__aenter__()
112
+ return await super().__aenter__()
113
+
114
+ @override
115
+ async def __aexit__(
116
+ self,
117
+ et: type[BaseException] | None,
118
+ exc: BaseException | None,
119
+ tb: TracebackType | None,
120
+ ) -> None:
121
+ _ = await self._stack.__aexit__(et, exc, tb)
122
+ _ = await super().__aexit__(et, exc, tb)
123
+
104
124
  @override
105
125
  def create_task(
106
126
  self,
@@ -116,6 +136,9 @@ class EnhancedTaskGroup(TaskGroup):
116
136
  coroutine = self._wrap_with_timeout(coroutine)
117
137
  return super().create_task(coroutine, name=name, context=context)
118
138
 
139
+ async def enter_async_context(self, cm: AbstractAsyncContextManager[_T], /) -> _T:
140
+ return await self._stack.enter_async_context(cm)
141
+
119
142
  async def _wrap_with_semaphore(
120
143
  self, semaphore: Semaphore, coroutine: _CoroutineLike[_T], /
121
144
  ) -> _T: