ez-a-sync 0.33.4__cp313-cp313-musllinux_1_2_i686.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.
Files changed (177) hide show
  1. a_sync/ENVIRONMENT_VARIABLES.py +42 -0
  2. a_sync/__init__.pxd +2 -0
  3. a_sync/__init__.py +145 -0
  4. a_sync/_smart.c +22830 -0
  5. a_sync/_smart.cpython-313-i386-linux-musl.so +0 -0
  6. a_sync/_smart.pxd +2 -0
  7. a_sync/_smart.pyi +202 -0
  8. a_sync/_smart.pyx +674 -0
  9. a_sync/_typing.py +258 -0
  10. a_sync/a_sync/__init__.py +60 -0
  11. a_sync/a_sync/_descriptor.c +20537 -0
  12. a_sync/a_sync/_descriptor.cpython-313-i386-linux-musl.so +0 -0
  13. a_sync/a_sync/_descriptor.pyi +33 -0
  14. a_sync/a_sync/_descriptor.pyx +422 -0
  15. a_sync/a_sync/_flags.c +6082 -0
  16. a_sync/a_sync/_flags.cpython-313-i386-linux-musl.so +0 -0
  17. a_sync/a_sync/_flags.pxd +3 -0
  18. a_sync/a_sync/_flags.pyx +92 -0
  19. a_sync/a_sync/_helpers.c +14529 -0
  20. a_sync/a_sync/_helpers.cpython-313-i386-linux-musl.so +0 -0
  21. a_sync/a_sync/_helpers.pxd +3 -0
  22. a_sync/a_sync/_helpers.pyi +10 -0
  23. a_sync/a_sync/_helpers.pyx +167 -0
  24. a_sync/a_sync/_kwargs.c +12202 -0
  25. a_sync/a_sync/_kwargs.cpython-313-i386-linux-musl.so +0 -0
  26. a_sync/a_sync/_kwargs.pxd +2 -0
  27. a_sync/a_sync/_kwargs.pyx +64 -0
  28. a_sync/a_sync/_meta.py +210 -0
  29. a_sync/a_sync/abstract.c +12420 -0
  30. a_sync/a_sync/abstract.cpython-313-i386-linux-musl.so +0 -0
  31. a_sync/a_sync/abstract.pyi +141 -0
  32. a_sync/a_sync/abstract.pyx +221 -0
  33. a_sync/a_sync/base.c +14940 -0
  34. a_sync/a_sync/base.cpython-313-i386-linux-musl.so +0 -0
  35. a_sync/a_sync/base.pyi +60 -0
  36. a_sync/a_sync/base.pyx +271 -0
  37. a_sync/a_sync/config.py +168 -0
  38. a_sync/a_sync/decorator.py +651 -0
  39. a_sync/a_sync/flags.c +5272 -0
  40. a_sync/a_sync/flags.cpython-313-i386-linux-musl.so +0 -0
  41. a_sync/a_sync/flags.pxd +72 -0
  42. a_sync/a_sync/flags.pyi +74 -0
  43. a_sync/a_sync/flags.pyx +72 -0
  44. a_sync/a_sync/function.c +37856 -0
  45. a_sync/a_sync/function.cpython-313-i386-linux-musl.so +0 -0
  46. a_sync/a_sync/function.pxd +28 -0
  47. a_sync/a_sync/function.pyi +571 -0
  48. a_sync/a_sync/function.pyx +1381 -0
  49. a_sync/a_sync/method.c +29662 -0
  50. a_sync/a_sync/method.cpython-313-i386-linux-musl.so +0 -0
  51. a_sync/a_sync/method.pxd +9 -0
  52. a_sync/a_sync/method.pyi +523 -0
  53. a_sync/a_sync/method.pyx +1023 -0
  54. a_sync/a_sync/modifiers/__init__.pxd +1 -0
  55. a_sync/a_sync/modifiers/__init__.py +101 -0
  56. a_sync/a_sync/modifiers/cache/__init__.py +160 -0
  57. a_sync/a_sync/modifiers/cache/memory.py +165 -0
  58. a_sync/a_sync/modifiers/limiter.py +132 -0
  59. a_sync/a_sync/modifiers/manager.c +16157 -0
  60. a_sync/a_sync/modifiers/manager.cpython-313-i386-linux-musl.so +0 -0
  61. a_sync/a_sync/modifiers/manager.pxd +5 -0
  62. a_sync/a_sync/modifiers/manager.pyi +219 -0
  63. a_sync/a_sync/modifiers/manager.pyx +299 -0
  64. a_sync/a_sync/modifiers/semaphores.py +173 -0
  65. a_sync/a_sync/property.c +27268 -0
  66. a_sync/a_sync/property.cpython-313-i386-linux-musl.so +0 -0
  67. a_sync/a_sync/property.pyi +376 -0
  68. a_sync/a_sync/property.pyx +819 -0
  69. a_sync/a_sync/singleton.py +63 -0
  70. a_sync/aliases.py +3 -0
  71. a_sync/async_property/__init__.pxd +1 -0
  72. a_sync/async_property/__init__.py +1 -0
  73. a_sync/async_property/cached.c +20397 -0
  74. a_sync/async_property/cached.cpython-313-i386-linux-musl.so +0 -0
  75. a_sync/async_property/cached.pxd +10 -0
  76. a_sync/async_property/cached.pyi +45 -0
  77. a_sync/async_property/cached.pyx +178 -0
  78. a_sync/async_property/proxy.c +34662 -0
  79. a_sync/async_property/proxy.cpython-313-i386-linux-musl.so +0 -0
  80. a_sync/async_property/proxy.pxd +2 -0
  81. a_sync/async_property/proxy.pyi +124 -0
  82. a_sync/async_property/proxy.pyx +474 -0
  83. a_sync/asyncio/__init__.pxd +6 -0
  84. a_sync/asyncio/__init__.py +164 -0
  85. a_sync/asyncio/as_completed.c +18849 -0
  86. a_sync/asyncio/as_completed.cpython-313-i386-linux-musl.so +0 -0
  87. a_sync/asyncio/as_completed.pxd +8 -0
  88. a_sync/asyncio/as_completed.pyi +109 -0
  89. a_sync/asyncio/as_completed.pyx +269 -0
  90. a_sync/asyncio/create_task.c +15912 -0
  91. a_sync/asyncio/create_task.cpython-313-i386-linux-musl.so +0 -0
  92. a_sync/asyncio/create_task.pxd +2 -0
  93. a_sync/asyncio/create_task.pyi +51 -0
  94. a_sync/asyncio/create_task.pyx +271 -0
  95. a_sync/asyncio/gather.c +16687 -0
  96. a_sync/asyncio/gather.cpython-313-i386-linux-musl.so +0 -0
  97. a_sync/asyncio/gather.pyi +107 -0
  98. a_sync/asyncio/gather.pyx +218 -0
  99. a_sync/asyncio/igather.c +13080 -0
  100. a_sync/asyncio/igather.cpython-313-i386-linux-musl.so +0 -0
  101. a_sync/asyncio/igather.pxd +1 -0
  102. a_sync/asyncio/igather.pyi +8 -0
  103. a_sync/asyncio/igather.pyx +183 -0
  104. a_sync/asyncio/sleep.c +9601 -0
  105. a_sync/asyncio/sleep.cpython-313-i386-linux-musl.so +0 -0
  106. a_sync/asyncio/sleep.pyi +14 -0
  107. a_sync/asyncio/sleep.pyx +49 -0
  108. a_sync/debugging.c +15370 -0
  109. a_sync/debugging.cpython-313-i386-linux-musl.so +0 -0
  110. a_sync/debugging.pyi +76 -0
  111. a_sync/debugging.pyx +107 -0
  112. a_sync/exceptions.c +13320 -0
  113. a_sync/exceptions.cpython-313-i386-linux-musl.so +0 -0
  114. a_sync/exceptions.pyi +376 -0
  115. a_sync/exceptions.pyx +446 -0
  116. a_sync/executor.py +619 -0
  117. a_sync/functools.c +12746 -0
  118. a_sync/functools.cpython-313-i386-linux-musl.so +0 -0
  119. a_sync/functools.pxd +7 -0
  120. a_sync/functools.pyi +33 -0
  121. a_sync/functools.pyx +139 -0
  122. a_sync/future.py +1497 -0
  123. a_sync/iter.c +37279 -0
  124. a_sync/iter.cpython-313-i386-linux-musl.so +0 -0
  125. a_sync/iter.pxd +11 -0
  126. a_sync/iter.pyi +370 -0
  127. a_sync/iter.pyx +981 -0
  128. a_sync/primitives/__init__.pxd +1 -0
  129. a_sync/primitives/__init__.py +53 -0
  130. a_sync/primitives/_debug.c +15765 -0
  131. a_sync/primitives/_debug.cpython-313-i386-linux-musl.so +0 -0
  132. a_sync/primitives/_debug.pxd +12 -0
  133. a_sync/primitives/_debug.pyi +52 -0
  134. a_sync/primitives/_debug.pyx +223 -0
  135. a_sync/primitives/_loggable.c +11538 -0
  136. a_sync/primitives/_loggable.cpython-313-i386-linux-musl.so +0 -0
  137. a_sync/primitives/_loggable.pxd +4 -0
  138. a_sync/primitives/_loggable.pyi +66 -0
  139. a_sync/primitives/_loggable.pyx +102 -0
  140. a_sync/primitives/locks/__init__.pxd +8 -0
  141. a_sync/primitives/locks/__init__.py +17 -0
  142. a_sync/primitives/locks/counter.c +17938 -0
  143. a_sync/primitives/locks/counter.cpython-313-i386-linux-musl.so +0 -0
  144. a_sync/primitives/locks/counter.pxd +12 -0
  145. a_sync/primitives/locks/counter.pyi +151 -0
  146. a_sync/primitives/locks/counter.pyx +267 -0
  147. a_sync/primitives/locks/event.c +17072 -0
  148. a_sync/primitives/locks/event.cpython-313-i386-linux-musl.so +0 -0
  149. a_sync/primitives/locks/event.pxd +22 -0
  150. a_sync/primitives/locks/event.pyi +43 -0
  151. a_sync/primitives/locks/event.pyx +185 -0
  152. a_sync/primitives/locks/prio_semaphore.c +25635 -0
  153. a_sync/primitives/locks/prio_semaphore.cpython-313-i386-linux-musl.so +0 -0
  154. a_sync/primitives/locks/prio_semaphore.pxd +25 -0
  155. a_sync/primitives/locks/prio_semaphore.pyi +217 -0
  156. a_sync/primitives/locks/prio_semaphore.pyx +597 -0
  157. a_sync/primitives/locks/semaphore.c +26553 -0
  158. a_sync/primitives/locks/semaphore.cpython-313-i386-linux-musl.so +0 -0
  159. a_sync/primitives/locks/semaphore.pxd +21 -0
  160. a_sync/primitives/locks/semaphore.pyi +197 -0
  161. a_sync/primitives/locks/semaphore.pyx +454 -0
  162. a_sync/primitives/queue.py +1026 -0
  163. a_sync/py.typed +0 -0
  164. a_sync/sphinx/__init__.py +3 -0
  165. a_sync/sphinx/ext.py +289 -0
  166. a_sync/task.py +934 -0
  167. a_sync/utils/__init__.py +105 -0
  168. a_sync/utils/iterators.py +297 -0
  169. a_sync/utils/repr.c +15866 -0
  170. a_sync/utils/repr.cpython-313-i386-linux-musl.so +0 -0
  171. a_sync/utils/repr.pyi +2 -0
  172. a_sync/utils/repr.pyx +73 -0
  173. ez_a_sync-0.33.4.dist-info/METADATA +368 -0
  174. ez_a_sync-0.33.4.dist-info/RECORD +177 -0
  175. ez_a_sync-0.33.4.dist-info/WHEEL +5 -0
  176. ez_a_sync-0.33.4.dist-info/licenses/LICENSE.txt +17 -0
  177. ez_a_sync-0.33.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,9 @@
1
+ from a_sync.a_sync.function cimport _ASyncFunction
2
+ cdef class _ASyncBoundMethod(_ASyncFunction):
3
+ cdef readonly object __weakself__
4
+ cdef readonly bint _is_async_def
5
+ cdef readonly object _cache_handle
6
+ cdef object c_map(self, tuple iterables, object concurrency, str task_name, dict kwargs)
7
+ cdef object __c_self__(self)
8
+ cdef bint _is_a_sync_instance(object instance)
9
+ cdef void _update_cache_timer(str field_name, object instance, _ASyncBoundMethod bound)
@@ -0,0 +1,523 @@
1
+ """
2
+ This module provides classes for implementing dual-functional sync/async methods in Python.
3
+
4
+ It includes descriptors and bound methods that can be used to create flexible
5
+ asynchronous interfaces, allowing methods to be called both synchronously and
6
+ asynchronously based on various conditions and configurations.
7
+ """
8
+
9
+ from a_sync._typing import *
10
+ import functools
11
+ import logging
12
+ import weakref
13
+ from _typeshed import Incomplete
14
+ from a_sync import TaskMapping as TaskMapping
15
+ from a_sync.a_sync._descriptor import ASyncDescriptor as ASyncDescriptor
16
+ from a_sync.a_sync.abstract import ASyncABC as ASyncABC
17
+ from a_sync.a_sync.function import (
18
+ ASyncFunction as ASyncFunction,
19
+ ASyncFunctionAsyncDefault as ASyncFunctionAsyncDefault,
20
+ ASyncFunctionSyncDefault as ASyncFunctionSyncDefault,
21
+ )
22
+ from typing import Any, final
23
+
24
+ METHOD_CACHE_TTL: Literal[3600]
25
+ logger: logging.Logger
26
+
27
+ class ASyncMethodDescriptor(ASyncDescriptor[I, P, T]):
28
+ """
29
+ A descriptor for managing methods that can be called both synchronously and asynchronously.
30
+
31
+ This class provides the core functionality for binding methods to instances and determining
32
+ the execution mode ("sync" or "async") based on various conditions, such as the instance type,
33
+ the method\'s default setting, or specific flags passed during the method call.
34
+
35
+ The descriptor is responsible for creating an appropriate bound method when accessed,
36
+ which is the actual object that can be called in both synchronous and asynchronous contexts.
37
+ It can create different types of bound methods (`ASyncBoundMethodSyncDefault`,
38
+ `ASyncBoundMethodAsyncDefault`, or `ASyncBoundMethod`) based on the default mode or instance type.
39
+
40
+ If the default mode is explicitly set to "sync" or "async", it creates `ASyncBoundMethodSyncDefault`
41
+ or `ASyncBoundMethodAsyncDefault` respectively. If neither is set, it defaults to creating an
42
+ `ASyncBoundMethod`. For instances of :class:`ASyncABC`, it checks the `__a_sync_instance_should_await__`
43
+ attribute to decide the type of bound method to create.
44
+
45
+ It also manages cache handles for bound methods and prevents setting or deleting the descriptor.
46
+
47
+ Examples:
48
+ >>> class MyClass:
49
+ ... @ASyncMethodDescriptor
50
+ ... async def my_method(self):
51
+ ... return "Hello, World!"
52
+ ...
53
+ >>> obj = MyClass()
54
+ >>> await obj.my_method()
55
+ \'Hello, World!\'
56
+ >>> obj.my_method(sync=True)
57
+ \'Hello, World!\'
58
+
59
+ See Also:
60
+ - :class:`ASyncBoundMethod`
61
+ - :class:`ASyncFunction`
62
+ """
63
+
64
+ __wrapped__: AnyFn[P, T]
65
+ async def __call__(self, instance: I, *args: P.args, **kwargs: P.kwargs) -> T:
66
+ """
67
+ Asynchronously call the method.
68
+
69
+ Args:
70
+ instance: The instance the method is bound to.
71
+ *args: Positional arguments.
72
+ **kwargs: Keyword arguments.
73
+
74
+ Examples:
75
+ >>> descriptor = ASyncMethodDescriptor(my_async_function)
76
+ >>> await descriptor(instance, arg1, arg2, kwarg1=value1)
77
+ """
78
+
79
+ @overload
80
+ def __get__(self, instance: None, owner: Type[I]) -> Self: ...
81
+ @overload
82
+ def __get__(self, instance: I, owner: Type[I]) -> ASyncBoundMethod[I, P, T]: ...
83
+ def __set__(self, instance, value) -> None:
84
+ """
85
+ Prevent setting the descriptor.
86
+
87
+ Args:
88
+ instance: The instance.
89
+ value: The value to set.
90
+
91
+ Raises:
92
+ RuntimeError: Always raised to prevent setting.
93
+
94
+ Examples:
95
+ >>> descriptor = ASyncMethodDescriptor(my_function)
96
+ >>> descriptor.__set__(instance, value)
97
+ RuntimeError: cannot set field_name, descriptor is what you get. sorry.
98
+ """
99
+
100
+ def __delete__(self, instance) -> None:
101
+ """
102
+ Prevent deleting the descriptor.
103
+
104
+ Args:
105
+ instance: The instance.
106
+
107
+ Raises:
108
+ RuntimeError: Always raised to prevent deletion.
109
+
110
+ Examples:
111
+ >>> descriptor = ASyncMethodDescriptor(my_function)
112
+ >>> descriptor.__delete__(instance)
113
+ RuntimeError: cannot delete field_name, you're stuck with descriptor forever. sorry.
114
+ """
115
+
116
+ @functools.cached_property
117
+ def __is_async_def__(self) -> bool:
118
+ """
119
+ Check if the wrapped function is a coroutine function.
120
+
121
+ Examples:
122
+ >>> descriptor = ASyncMethodDescriptor(my_function)
123
+ >>> descriptor.__is_async_def__
124
+ True
125
+ """
126
+
127
+ @final
128
+ class ASyncMethodDescriptorSyncDefault(ASyncMethodDescriptor[I, P, T]):
129
+ """
130
+ A descriptor for :class:`ASyncBoundMethodSyncDefault` objects.
131
+
132
+ This class extends :class:`ASyncMethodDescriptor` to provide a synchronous
133
+ default behavior for method calls. It specifically creates `ASyncBoundMethodSyncDefault`
134
+ instances, which are specialized versions of `ASyncBoundMethod` with synchronous default behavior.
135
+
136
+ Examples:
137
+ >>> class MyClass:
138
+ ... @ASyncMethodDescriptorSyncDefault
139
+ ... def my_method(self):
140
+ ... return "Hello, World!"
141
+ ...
142
+ >>> obj = MyClass()
143
+ >>> obj.my_method()
144
+ \'Hello, World!\'
145
+ >>> coro = obj.my_method(sync=False)
146
+ >>> coro
147
+ <coroutine object MyClass.my_method at 0x7fb4f5fb49c0>
148
+ >>> await coro
149
+ \'Hello, World!\'
150
+
151
+ See Also:
152
+ - :class:`ASyncBoundMethodSyncDefault`
153
+ - :class:`ASyncFunctionSyncDefault`
154
+ """
155
+
156
+ default: str
157
+ any: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], bool]
158
+ all: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], bool]
159
+ min: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], T]
160
+ max: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], T]
161
+ sum: ASyncFunctionSyncDefault[Concatenate[AnyIterable[I], P], T]
162
+ @overload
163
+ def __get__(
164
+ self, instance: None, owner: Type[I]
165
+ ) -> ASyncMethodDescriptorSyncDefault[I, P, T]: ...
166
+ @overload
167
+ def __get__(self, instance: I, owner: Type[I]) -> ASyncBoundMethodSyncDefault[I, P, T]: ...
168
+
169
+ @final
170
+ class ASyncMethodDescriptorAsyncDefault(ASyncMethodDescriptor[I, P, T]):
171
+ """
172
+ A descriptor for asynchronous methods with an asynchronous default.
173
+
174
+ This class extends :class:`ASyncMethodDescriptor` to provide an asynchronous default
175
+ behavior for method calls. It specifically creates `ASyncBoundMethodAsyncDefault`
176
+ instances, which are specialized versions of `ASyncBoundMethod` with asynchronous default behavior.
177
+
178
+ Examples:
179
+ >>> class MyClass:
180
+ ... @ASyncMethodDescriptorAsyncDefault
181
+ ... async def my_method(self):
182
+ ... return "Hello, World!"
183
+ ...
184
+ >>> obj = MyClass()
185
+ >>> coro = obj.my_method()
186
+ >>> coro
187
+ <coroutine object MyClass.my_method at 0x7fb4f5fb49c0>
188
+ >>> await coro
189
+ >>> obj.my_method(sync=True)
190
+ \'Hello, World!\'
191
+
192
+ See Also:
193
+ - :class:`ASyncBoundMethodAsyncDefault`
194
+ - :class:`ASyncFunctionAsyncDefault`
195
+ """
196
+
197
+ default: str
198
+ any: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], bool]
199
+ all: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], bool]
200
+ min: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], T]
201
+ max: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], T]
202
+ sum: ASyncFunctionAsyncDefault[Concatenate[AnyIterable[I], P], T]
203
+ @overload
204
+ def __get__(
205
+ self, instance: None, owner: Type[I]
206
+ ) -> ASyncMethodDescriptorAsyncDefault[I, P, T]: ...
207
+ @overload
208
+ def __get__(self, instance: I, owner: Type[I]) -> ASyncBoundMethodAsyncDefault[I, P, T]: ...
209
+
210
+ class ASyncBoundMethod(ASyncFunction[P, T], Generic[I, P, T]):
211
+ """
212
+ A bound method that can be called both synchronously and asynchronously.
213
+
214
+ This class represents a method bound to an instance, which can be called
215
+ either synchronously or asynchronously based on various conditions. It handles
216
+ caching of bound methods and includes logic for determining whether to await
217
+ the method call based on flags or default settings.
218
+
219
+ Examples:
220
+ >>> class MyClass:
221
+ ... def __init__(self, value):
222
+ ... self.value = value
223
+ ...
224
+ ... @ASyncMethodDescriptor
225
+ ... async def my_method(self):
226
+ ... return self.value
227
+ ...
228
+ >>> obj = MyClass(42)
229
+ >>> await obj.my_method()
230
+ 42
231
+ >>> obj.my_method(sync=True)
232
+ 42
233
+
234
+ See Also:
235
+ - :class:`ASyncMethodDescriptor`
236
+ - :class:`ASyncFunction`
237
+ """
238
+
239
+ __weakself__: weakref.ref[I]
240
+ __wrapped__: AnyFn[Concatenate[I, P], T]
241
+ def __init__(
242
+ self,
243
+ instance: I,
244
+ unbound: AnyFn[Concatenate[I, P], T],
245
+ async_def: bool,
246
+ **modifiers: Unpack[ModifierKwargs]
247
+ ) -> None:
248
+ """
249
+ Initialize the bound method.
250
+
251
+ Args:
252
+ instance: The instance to bind the method to.
253
+ unbound: The unbound function.
254
+ async_def: Whether the original function is an async def.
255
+ **modifiers: Additional modifiers for the function.
256
+
257
+ Examples:
258
+ >>> class MyClass:
259
+ ... def __init__(self, value):
260
+ ... self.value = value
261
+ ...
262
+ ... @ASyncMethodDescriptor
263
+ ... async def my_method(self):
264
+ ... return self.value
265
+ ...
266
+ >>> obj = MyClass(42)
267
+ >>> bound_method = ASyncBoundMethod(obj, MyClass.my_method, True)
268
+ """
269
+
270
+ @overload
271
+ def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
272
+ @overload
273
+ def __call__(
274
+ self, *args: P.args, sync: Literal[False], **kwargs: P.kwargs
275
+ ) -> Coroutine[Any, Any, T]: ...
276
+ @overload
277
+ def __call__(self, *args: P.args, asynchronous: Literal[False], **kwargs: P.kwargs) -> T: ...
278
+ @overload
279
+ def __call__(
280
+ self, *args: P.args, asynchronous: Literal[True], **kwargs: P.kwargs
281
+ ) -> Coroutine[Any, Any, T]: ...
282
+ @overload
283
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> MaybeCoro[T]: ...
284
+ @property
285
+ def __self__(self) -> I:
286
+ """
287
+ Get the instance the method is bound to.
288
+
289
+ Raises:
290
+ ReferenceError: If the instance has been garbage collected.
291
+
292
+ Examples:
293
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
294
+ >>> bound_method.__self__
295
+ <MyClass instance>
296
+ """
297
+
298
+ @functools.cached_property
299
+ def __bound_to_a_sync_instance__(self) -> bool:
300
+ """
301
+ Check if the method is bound to an ASyncABC instance.
302
+
303
+ Examples:
304
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
305
+ >>> bound_method.__bound_to_a_sync_instance__
306
+ True
307
+ """
308
+
309
+ def map(
310
+ self,
311
+ *iterables: AnyIterable[I],
312
+ concurrency: Optional[int] = None,
313
+ task_name: str = "",
314
+ **kwargs: P.kwargs
315
+ ) -> TaskMapping[I, T]:
316
+ """
317
+ Create a TaskMapping for this method.
318
+
319
+ Args:
320
+ *iterables: Iterables to map over.
321
+ concurrency: Optional concurrency limit.
322
+ task_name: Optional name for the task.
323
+ **kwargs: Additional keyword arguments.
324
+
325
+ Returns:
326
+ A TaskMapping instance for this method.
327
+
328
+ Examples:
329
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
330
+ >>> task_mapping = bound_method.map(iterable1, iterable2, concurrency=5)
331
+ TODO briefly include how someone would then use task_mapping
332
+ """
333
+
334
+ async def any(
335
+ self,
336
+ *iterables: AnyIterable[I],
337
+ concurrency: Optional[int] = None,
338
+ task_name: str = "",
339
+ **kwargs: P.kwargs
340
+ ) -> bool:
341
+ """
342
+ Check if any of the results are truthy.
343
+
344
+ Args:
345
+ *iterables: Iterables to map over.
346
+ concurrency: Optional concurrency limit.
347
+ task_name: Optional name for the task.
348
+ **kwargs: Additional keyword arguments.
349
+
350
+ Examples:
351
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
352
+ >>> result = await bound_method.any(iterable1, iterable2)
353
+ """
354
+
355
+ async def all(
356
+ self,
357
+ *iterables: AnyIterable[I],
358
+ concurrency: Optional[int] = None,
359
+ task_name: str = "",
360
+ **kwargs: P.kwargs
361
+ ) -> bool:
362
+ """
363
+ Check if all of the results are truthy.
364
+
365
+ Args:
366
+ *iterables: Iterables to map over.
367
+ concurrency: Optional concurrency limit.
368
+ task_name: Optional name for the task.
369
+ **kwargs: Additional keyword arguments.
370
+
371
+ Examples:
372
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
373
+ >>> result = await bound_method.all(iterable1, iterable2)
374
+ """
375
+
376
+ async def min(
377
+ self,
378
+ *iterables: AnyIterable[I],
379
+ concurrency: Optional[int] = None,
380
+ task_name: str = "",
381
+ **kwargs: P.kwargs
382
+ ) -> T:
383
+ """
384
+ Find the minimum result.
385
+
386
+ Args:
387
+ *iterables: Iterables to map over.
388
+ concurrency: Optional concurrency limit.
389
+ task_name: Optional name for the task.
390
+ **kwargs: Additional keyword arguments.
391
+
392
+ Examples:
393
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
394
+ >>> result = await bound_method.min(iterable1, iterable2)
395
+ """
396
+
397
+ async def max(
398
+ self,
399
+ *iterables: AnyIterable[I],
400
+ concurrency: Optional[int] = None,
401
+ task_name: str = "",
402
+ **kwargs: P.kwargs
403
+ ) -> T:
404
+ """
405
+ Find the maximum result.
406
+
407
+ Args:
408
+ *iterables: Iterables to map over.
409
+ concurrency: Optional concurrency limit.
410
+ task_name: Optional name for the task.
411
+ **kwargs: Additional keyword arguments.
412
+
413
+ Examples:
414
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
415
+ >>> result = await bound_method.max(iterable1, iterable2)
416
+ """
417
+
418
+ async def sum(
419
+ self,
420
+ *iterables: AnyIterable[I],
421
+ concurrency: Optional[int] = None,
422
+ task_name: str = "",
423
+ **kwargs: P.kwargs
424
+ ) -> T:
425
+ """
426
+ Calculate the sum of the results.
427
+
428
+ Args:
429
+ *iterables: Iterables to map over.
430
+ concurrency: Optional concurrency limit.
431
+ task_name: Optional name for the task.
432
+ **kwargs: Additional keyword arguments.
433
+
434
+ Examples:
435
+ >>> bound_method = ASyncBoundMethod(instance, my_function, True)
436
+ >>> result = await bound_method.sum(iterable1, iterable2)
437
+ """
438
+
439
+ class ASyncBoundMethodSyncDefault(ASyncBoundMethod[I, P, T]):
440
+ """
441
+ A bound method with synchronous default behavior.
442
+
443
+ This class is a specialized version of :class:`ASyncBoundMethod` that defaults to synchronous execution.
444
+ It overrides the `__call__` method to enforce synchronous default behavior.
445
+
446
+ Examples:
447
+ >>> class MyClass:
448
+ ... def __init__(self, value):
449
+ ... self.value = value
450
+ ...
451
+ ... @ASyncMethodDescriptorSyncDefault
452
+ ... def my_method(self):
453
+ ... return self.value
454
+ ...
455
+ >>> obj = MyClass(42)
456
+ >>> obj.my_method()
457
+ 42
458
+ >>> await obj.my_method(sync=False)
459
+ 42
460
+
461
+ See Also:
462
+ - :class:`ASyncBoundMethod`
463
+ - :class:`ASyncMethodDescriptorSyncDefault`
464
+ """
465
+
466
+ @overload
467
+ def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
468
+ @overload
469
+ def __call__(
470
+ self, *args: P.args, sync: Literal[False], **kwargs: P.kwargs
471
+ ) -> Coroutine[Any, Any, T]: ...
472
+ @overload
473
+ def __call__(self, *args: P.args, asynchronous: Literal[False], **kwargs: P.kwargs) -> T: ...
474
+ @overload
475
+ def __call__(
476
+ self, *args: P.args, asynchronous: Literal[True], **kwargs: P.kwargs
477
+ ) -> Coroutine[Any, Any, T]: ...
478
+ @overload
479
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T: ...
480
+ __call__: Incomplete
481
+
482
+ class ASyncBoundMethodAsyncDefault(ASyncBoundMethod[I, P, T]):
483
+ """
484
+ A bound method with asynchronous default behavior.
485
+
486
+ This class is a specialized version of :class:`ASyncBoundMethod` that defaults to asynchronous execution.
487
+ It overrides the `__call__` method to enforce asynchronous default behavior.
488
+
489
+ Examples:
490
+ >>> class MyClass:
491
+ ... def __init__(self, value):
492
+ ... self.value = value
493
+ ...
494
+ ... @ASyncMethodDescriptorAsyncDefault
495
+ ... async def my_method(self):
496
+ ... return self.value
497
+ ...
498
+ >>> obj = MyClass(42)
499
+ >>> await obj.my_method()
500
+ 42
501
+ >>> obj.my_method(sync=True)
502
+ 42
503
+
504
+ See Also:
505
+ - :class:`ASyncBoundMethod`
506
+ - :class:`ASyncMethodDescriptorAsyncDefault`
507
+ """
508
+
509
+ @overload
510
+ def __call__(self, *args: P.args, sync: Literal[True], **kwargs: P.kwargs) -> T: ...
511
+ @overload
512
+ def __call__(
513
+ self, *args: P.args, sync: Literal[False], **kwargs: P.kwargs
514
+ ) -> Coroutine[Any, Any, T]: ...
515
+ @overload
516
+ def __call__(self, *args: P.args, asynchronous: Literal[False], **kwargs: P.kwargs) -> T: ...
517
+ @overload
518
+ def __call__(
519
+ self, *args: P.args, asynchronous: Literal[True], **kwargs: P.kwargs
520
+ ) -> Coroutine[Any, Any, T]: ...
521
+ @overload
522
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> Coroutine[Any, Any, T]: ...
523
+ __call__: Incomplete