ez-a-sync 0.22.14__py3-none-any.whl → 0.22.15__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.

Potentially problematic release.


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

Files changed (73) hide show
  1. a_sync/ENVIRONMENT_VARIABLES.py +4 -3
  2. a_sync/__init__.py +30 -12
  3. a_sync/_smart.py +132 -28
  4. a_sync/_typing.py +56 -12
  5. a_sync/a_sync/__init__.py +35 -10
  6. a_sync/a_sync/_descriptor.py +74 -26
  7. a_sync/a_sync/_flags.py +14 -6
  8. a_sync/a_sync/_helpers.py +8 -7
  9. a_sync/a_sync/_kwargs.py +3 -2
  10. a_sync/a_sync/_meta.py +120 -28
  11. a_sync/a_sync/abstract.py +102 -28
  12. a_sync/a_sync/base.py +34 -16
  13. a_sync/a_sync/config.py +47 -13
  14. a_sync/a_sync/decorator.py +239 -117
  15. a_sync/a_sync/function.py +416 -146
  16. a_sync/a_sync/method.py +197 -59
  17. a_sync/a_sync/modifiers/__init__.py +47 -5
  18. a_sync/a_sync/modifiers/cache/__init__.py +46 -17
  19. a_sync/a_sync/modifiers/cache/memory.py +86 -20
  20. a_sync/a_sync/modifiers/limiter.py +52 -22
  21. a_sync/a_sync/modifiers/manager.py +98 -16
  22. a_sync/a_sync/modifiers/semaphores.py +48 -15
  23. a_sync/a_sync/property.py +383 -82
  24. a_sync/a_sync/singleton.py +1 -0
  25. a_sync/aliases.py +0 -1
  26. a_sync/asyncio/__init__.py +4 -1
  27. a_sync/asyncio/as_completed.py +177 -49
  28. a_sync/asyncio/create_task.py +31 -17
  29. a_sync/asyncio/gather.py +72 -52
  30. a_sync/asyncio/utils.py +3 -3
  31. a_sync/exceptions.py +78 -23
  32. a_sync/executor.py +118 -71
  33. a_sync/future.py +575 -158
  34. a_sync/iter.py +110 -50
  35. a_sync/primitives/__init__.py +14 -2
  36. a_sync/primitives/_debug.py +13 -13
  37. a_sync/primitives/_loggable.py +5 -4
  38. a_sync/primitives/locks/__init__.py +5 -2
  39. a_sync/primitives/locks/counter.py +38 -36
  40. a_sync/primitives/locks/event.py +21 -7
  41. a_sync/primitives/locks/prio_semaphore.py +182 -62
  42. a_sync/primitives/locks/semaphore.py +78 -77
  43. a_sync/primitives/queue.py +560 -58
  44. a_sync/sphinx/__init__.py +0 -1
  45. a_sync/sphinx/ext.py +160 -50
  46. a_sync/task.py +262 -97
  47. a_sync/utils/__init__.py +12 -6
  48. a_sync/utils/iterators.py +127 -43
  49. {ez_a_sync-0.22.14.dist-info → ez_a_sync-0.22.15.dist-info}/METADATA +1 -1
  50. ez_a_sync-0.22.15.dist-info/RECORD +74 -0
  51. {ez_a_sync-0.22.14.dist-info → ez_a_sync-0.22.15.dist-info}/WHEEL +1 -1
  52. tests/conftest.py +1 -2
  53. tests/executor.py +112 -9
  54. tests/fixtures.py +61 -32
  55. tests/test_abstract.py +7 -4
  56. tests/test_as_completed.py +54 -21
  57. tests/test_base.py +66 -17
  58. tests/test_cache.py +31 -15
  59. tests/test_decorator.py +54 -28
  60. tests/test_executor.py +8 -13
  61. tests/test_future.py +45 -8
  62. tests/test_gather.py +8 -2
  63. tests/test_helpers.py +2 -0
  64. tests/test_iter.py +55 -13
  65. tests/test_limiter.py +5 -3
  66. tests/test_meta.py +23 -9
  67. tests/test_modified.py +4 -1
  68. tests/test_semaphore.py +15 -8
  69. tests/test_singleton.py +15 -10
  70. tests/test_task.py +126 -28
  71. ez_a_sync-0.22.14.dist-info/RECORD +0 -74
  72. {ez_a_sync-0.22.14.dist-info → ez_a_sync-0.22.15.dist-info}/LICENSE.txt +0 -0
  73. {ez_a_sync-0.22.14.dist-info → ez_a_sync-0.22.15.dist-info}/top_level.txt +0 -0
a_sync/sphinx/__init__.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
1
  from a_sync.sphinx import ext
3
2
 
4
3
  __all__ = ["ext"]
a_sync/sphinx/ext.py CHANGED
@@ -32,6 +32,7 @@ syntax.
32
32
 
33
33
  Use ``.. autotask::`` to alternatively manually document a task.
34
34
  """
35
+
35
36
  from inspect import signature
36
37
 
37
38
  from docutils import nodes
@@ -39,151 +40,260 @@ from sphinx.domains.python import PyFunction, PyMethod
39
40
  from sphinx.ext.autodoc import FunctionDocumenter, MethodDocumenter
40
41
 
41
42
  from a_sync.a_sync._descriptor import ASyncDescriptor
42
- from a_sync.a_sync.function import ASyncFunction, ASyncFunctionAsyncDefault, ASyncFunctionSyncDefault
43
+ from a_sync.a_sync.function import (
44
+ ASyncFunction,
45
+ ASyncFunctionAsyncDefault,
46
+ ASyncFunctionSyncDefault,
47
+ )
43
48
  from a_sync.iter import ASyncGeneratorFunction
44
49
 
45
50
 
46
-
47
51
  class _ASyncWrapperDocumenter:
52
+ """Base class for documenters that handle wrapped ASync functions."""
53
+
48
54
  typ: type
49
55
 
50
56
  @classmethod
51
57
  def can_document_member(cls, member, membername, isattr, parent):
52
- return isinstance(member, cls.typ) and getattr(member, '__wrapped__') is not None
58
+ """Determine if the member can be documented by this documenter.
59
+
60
+ Args:
61
+ member: The member to check.
62
+ membername: The name of the member.
63
+ isattr: Boolean indicating if the member is an attribute.
64
+ parent: The parent object.
65
+
66
+ Returns:
67
+ bool: True if the member can be documented, False otherwise.
68
+ """
69
+ return (
70
+ isinstance(member, cls.typ) and getattr(member, "__wrapped__") is not None
71
+ )
53
72
 
54
73
  def document_members(self, all_members=False):
74
+ """Document members of the object.
75
+
76
+ Args:
77
+ all_members: Boolean indicating if all members should be documented.
78
+ """
55
79
  pass
56
80
 
57
81
  def check_module(self):
58
- # Normally checks if *self.object* is really defined in the module
59
- # given by *self.modname*. But since functions decorated with the @task
60
- # decorator are instances living in the celery.local, we have to check
61
- # the wrapped function instead.
62
- wrapped = getattr(self.object, '__wrapped__', None)
63
- if wrapped and getattr(wrapped, '__module__') == self.modname:
82
+ """Check if the object is defined in the expected module.
83
+
84
+ Returns:
85
+ bool: True if the object is defined in the expected module, False otherwise.
86
+
87
+ Note:
88
+ Normally checks if *self.object* is really defined in the module
89
+ given by *self.modname*. But since functions decorated with the @task
90
+ decorator are instances living in the celery.local, we have to check
91
+ the wrapped function instead.
92
+ """
93
+ wrapped = getattr(self.object, "__wrapped__", None)
94
+ if wrapped and getattr(wrapped, "__module__") == self.modname:
64
95
  return True
65
96
  return super().check_module()
66
97
 
98
+
67
99
  class _ASyncFunctionDocumenter(_ASyncWrapperDocumenter, FunctionDocumenter):
100
+ """Documenter for ASyncFunction instances."""
101
+
68
102
  def format_args(self):
69
- wrapped = getattr(self.object, '__wrapped__', None)
103
+ """Format the arguments of the wrapped function.
104
+
105
+ Returns:
106
+ str: The formatted arguments.
107
+ """
108
+ wrapped = getattr(self.object, "__wrapped__", None)
70
109
  if wrapped is not None:
71
110
  sig = signature(wrapped)
72
111
  if "self" in sig.parameters or "cls" in sig.parameters:
73
112
  sig = sig.replace(parameters=list(sig.parameters.values())[1:])
74
113
  return str(sig)
75
- return ''
114
+ return ""
115
+
76
116
 
77
117
  class _ASyncMethodDocumenter(_ASyncWrapperDocumenter, MethodDocumenter):
118
+ """Documenter for ASyncMethod instances."""
119
+
78
120
  def format_args(self):
79
- wrapped = getattr(self.object, '__wrapped__')
121
+ """Format the arguments of the wrapped method.
122
+
123
+ Returns:
124
+ str: The formatted arguments.
125
+ """
126
+ wrapped = getattr(self.object, "__wrapped__")
80
127
  if wrapped is not None:
81
128
  return str(signature(wrapped))
82
- return ''
83
-
129
+ return ""
130
+
131
+
84
132
  class _ASyncDirective:
133
+ """Base class for ASync directives."""
134
+
85
135
  prefix_env: str
136
+
86
137
  def get_signature_prefix(self, sig):
138
+ """Get the signature prefix for the directive.
139
+
140
+ Args:
141
+ sig: The signature to process.
142
+
143
+ Returns:
144
+ list: A list of nodes representing the signature prefix.
145
+ """
87
146
  return [nodes.Text(getattr(self.env.config, self.prefix_env))]
88
147
 
148
+
89
149
  class _ASyncFunctionDirective(_ASyncDirective, PyFunction):
150
+ """Directive for ASyncFunction instances."""
151
+
90
152
  pass
91
153
 
154
+
92
155
  class _ASyncMethodDirective(_ASyncDirective, PyMethod):
156
+ """Directive for ASyncMethod instances."""
157
+
93
158
  pass
94
-
159
+
95
160
 
96
161
  class ASyncFunctionDocumenter(_ASyncFunctionDocumenter):
97
162
  """Document ASyncFunction instance definitions."""
98
- objtype = 'a_sync_function'
163
+
164
+ objtype = "a_sync_function"
99
165
  typ = ASyncFunction
100
166
  priority = 15
101
- #member_order = 11
167
+ # member_order = 11
168
+
102
169
 
103
170
  class ASyncFunctionSyncDocumenter(_ASyncFunctionDocumenter):
104
- """Document ASyncFunction instance definitions."""
105
- objtype = 'a_sync_function_sync'
171
+ """Document ASyncFunctionSyncDefault instance definitions."""
172
+
173
+ objtype = "a_sync_function_sync"
106
174
  typ = ASyncFunctionSyncDefault
107
175
  priority = 14
108
- #member_order = 11
176
+ # member_order = 11
177
+
109
178
 
110
179
  class ASyncFunctionAsyncDocumenter(_ASyncFunctionDocumenter):
111
- """Document ASyncFunction instance definitions."""
112
- objtype = 'a_sync_function_async'
180
+ """Document ASyncFunctionAsyncDefault instance definitions."""
181
+
182
+ objtype = "a_sync_function_async"
113
183
  typ = ASyncFunctionAsyncDefault
114
184
  priority = 13
115
- #member_order = 11
185
+ # member_order = 11
116
186
 
117
187
 
118
188
  class ASyncFunctionDirective(_ASyncFunctionDirective):
189
+ """Directive for ASyncFunction instances."""
190
+
119
191
  prefix_env = "a_sync_function_prefix"
120
192
 
193
+
121
194
  class ASyncFunctionSyncDirective(_ASyncFunctionDirective):
195
+ """Directive for ASyncFunctionSyncDefault instances."""
196
+
122
197
  prefix_env = "a_sync_function_sync_prefix"
123
198
 
199
+
124
200
  class ASyncFunctionAsyncDirective(_ASyncFunctionDirective):
201
+ """Directive for ASyncFunctionAsyncDefault instances."""
202
+
125
203
  prefix_env = "a_sync_function_async_prefix"
126
204
 
127
205
 
128
206
  class ASyncDescriptorDocumenter(_ASyncMethodDocumenter):
129
207
  """Document ASyncDescriptor instance definitions."""
130
- objtype = 'a_sync_descriptor'
208
+
209
+ objtype = "a_sync_descriptor"
131
210
  typ = ASyncDescriptor
132
- #member_order = 11
211
+ # member_order = 11
133
212
 
134
213
 
135
214
  class ASyncDescriptorDirective(_ASyncMethodDirective):
136
- """Sphinx task directive."""
215
+ """Directive for ASyncDescriptor instances."""
216
+
137
217
  prefix_env = "a_sync_descriptor_prefix"
138
218
 
139
219
 
140
220
  class ASyncGeneratorFunctionDocumenter(_ASyncFunctionDocumenter):
141
- """Document ASyncFunction instance definitions."""
142
- objtype = 'a_sync_generator_function'
221
+ """Document ASyncGeneratorFunction instance definitions."""
222
+
223
+ objtype = "a_sync_generator_function"
143
224
  typ = ASyncGeneratorFunction
144
- #member_order = 11
225
+ # member_order = 11
145
226
 
146
227
 
147
228
  class ASyncGeneratorFunctionDirective(_ASyncFunctionDirective):
148
- """Sphinx task directive."""
229
+ """Directive for ASyncGeneratorFunction instances."""
230
+
149
231
  prefix_env = "a_sync_generator_function_prefix"
150
232
 
233
+
151
234
  def autodoc_skip_member_handler(app, what, name, obj, skip, options):
152
- """Handler for autodoc-skip-member event."""
153
- if isinstance(obj, (ASyncFunction, ASyncDescriptor, ASyncGeneratorFunction)) and getattr(obj, '__wrapped__'):
235
+ """Handler for autodoc-skip-member event.
236
+
237
+ Args:
238
+ app: The Sphinx application object.
239
+ what: The type of the object being documented.
240
+ name: The name of the object.
241
+ obj: The object itself.
242
+ skip: Boolean indicating if the member should be skipped.
243
+ options: The options for the autodoc directive.
244
+
245
+ Returns:
246
+ bool: True if the member should be skipped, False otherwise.
247
+ """
248
+ if isinstance(
249
+ obj, (ASyncFunction, ASyncDescriptor, ASyncGeneratorFunction)
250
+ ) and getattr(obj, "__wrapped__"):
154
251
  if skip:
155
252
  return False
156
253
  return None
157
254
 
158
255
 
159
256
  def setup(app):
160
- """Setup Sphinx extension."""
161
- app.setup_extension('sphinx.ext.autodoc')
162
-
257
+ """Setup Sphinx extension.
258
+
259
+ Args:
260
+ app: The Sphinx application object.
261
+
262
+ Returns:
263
+ dict: A dictionary with metadata about the extension.
264
+ """
265
+ app.setup_extension("sphinx.ext.autodoc")
266
+
163
267
  # function
164
268
  app.add_autodocumenter(ASyncFunctionDocumenter)
165
269
  app.add_autodocumenter(ASyncFunctionSyncDocumenter)
166
270
  app.add_autodocumenter(ASyncFunctionAsyncDocumenter)
167
- app.add_directive_to_domain('py', 'a_sync_function', ASyncFunctionDirective)
168
- app.add_directive_to_domain('py', 'a_sync_function_sync', ASyncFunctionSyncDirective)
169
- app.add_directive_to_domain('py', 'a_sync_function_async', ASyncFunctionAsyncDirective)
170
- app.add_config_value('a_sync_function_sync_prefix', 'ASyncFunction (sync)', True)
171
- app.add_config_value('a_sync_function_async_prefix', 'ASyncFunction (async)', True)
172
- app.add_config_value('a_sync_function_prefix', 'ASyncFunction', True)
271
+ app.add_directive_to_domain("py", "a_sync_function", ASyncFunctionDirective)
272
+ app.add_directive_to_domain(
273
+ "py", "a_sync_function_sync", ASyncFunctionSyncDirective
274
+ )
275
+ app.add_directive_to_domain(
276
+ "py", "a_sync_function_async", ASyncFunctionAsyncDirective
277
+ )
278
+ app.add_config_value("a_sync_function_sync_prefix", "ASyncFunction (sync)", True)
279
+ app.add_config_value("a_sync_function_async_prefix", "ASyncFunction (async)", True)
280
+ app.add_config_value("a_sync_function_prefix", "ASyncFunction", True)
173
281
 
174
282
  # descriptor
175
283
  app.add_autodocumenter(ASyncDescriptorDocumenter)
176
- app.add_directive_to_domain('py', 'a_sync_descriptor', ASyncDescriptorDirective)
177
- app.add_config_value('a_sync_descriptor_prefix', 'ASyncDescriptor', True)
284
+ app.add_directive_to_domain("py", "a_sync_descriptor", ASyncDescriptorDirective)
285
+ app.add_config_value("a_sync_descriptor_prefix", "ASyncDescriptor", True)
178
286
 
179
287
  # generator
180
-
288
+
181
289
  app.add_autodocumenter(ASyncGeneratorFunctionDocumenter)
182
- app.add_directive_to_domain('py', 'a_sync_generator_function', ASyncGeneratorFunctionDirective)
183
- app.add_config_value('a_sync_generator_function_prefix', 'ASyncGeneratorFunction', True)
290
+ app.add_directive_to_domain(
291
+ "py", "a_sync_generator_function", ASyncGeneratorFunctionDirective
292
+ )
293
+ app.add_config_value(
294
+ "a_sync_generator_function_prefix", "ASyncGeneratorFunction", True
295
+ )
184
296
 
185
- app.connect('autodoc-skip-member', autodoc_skip_member_handler)
297
+ app.connect("autodoc-skip-member", autodoc_skip_member_handler)
186
298
 
187
- return {
188
- 'parallel_read_safe': True
189
- }
299
+ return {"parallel_read_safe": True}