ez-a-sync 0.32.24__cp310-cp310-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_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.

Potentially problematic release.


This version of ez-a-sync might be problematic. Click here for more details.

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