python-cq 0.22.0__py3-none-any.whl → 0.22.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.
cq/__init__.py CHANGED
@@ -21,18 +21,17 @@ from ._core.queues.memory import MemoryQueue
21
21
  from ._core.related_events import AnyIORelatedEvents, RelatedEvents
22
22
 
23
23
  __all__ = (
24
- "__cq__",
24
+ "CQ",
25
25
  "AnyCommandBus",
26
26
  "AnyIORelatedEvents",
27
27
  "Bus",
28
- "CQ",
29
28
  "Command",
30
29
  "CommandBus",
31
30
  "Consumer",
32
31
  "ContextCommandPipeline",
33
32
  "ContextPipeline",
34
- "Delivery",
35
33
  "DIAdapter",
34
+ "Delivery",
36
35
  "Dispatcher",
37
36
  "Event",
38
37
  "EventBus",
@@ -46,6 +45,7 @@ __all__ = (
46
45
  "QueryBus",
47
46
  "Queue",
48
47
  "RelatedEvents",
48
+ "__cq__",
49
49
  "command_handler",
50
50
  "event_handler",
51
51
  "new_command_bus",
cq/_core/handler.py CHANGED
@@ -183,7 +183,7 @@ class HandlerDecorator[I, O]:
183
183
  and issubclass(message_or_handler_type, Handler)
184
184
  ):
185
185
  return self.__decorator(
186
- message_or_handler_type,
186
+ message_or_handler_type, # type: ignore[arg-type]
187
187
  fail_silently=fail_silently,
188
188
  )
189
189
 
cq/_core/middleware.py CHANGED
@@ -98,7 +98,7 @@ class _GeneratorMiddleware[**P, T]:
98
98
  while True:
99
99
  try:
100
100
  value = await call_next(*args, **kwargs)
101
- except BaseException as exc:
101
+ except BaseException as exc: # noqa: BLE001
102
102
  await generator.athrow(exc)
103
103
  else:
104
104
  await generator.asend(value)
cq/_core/queues/abc.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from abc import abstractmethod
2
2
  from collections.abc import AsyncIterable
3
- from typing import AsyncContextManager, Protocol, runtime_checkable
3
+ from contextlib import AbstractAsyncContextManager
4
+ from typing import Protocol, runtime_checkable
4
5
 
5
6
 
6
7
  @runtime_checkable
@@ -16,7 +17,7 @@ class Producer[T](Protocol):
16
17
 
17
18
 
18
19
  @runtime_checkable
19
- class Delivery[T](AsyncContextManager[T], Protocol):
20
+ class Delivery[T](AbstractAsyncContextManager[T], Protocol):
20
21
  __slots__ = ()
21
22
 
22
23
 
cq/_core/queues/memory.py CHANGED
@@ -51,10 +51,10 @@ class MemoryQueue[T](Queue[T]):
51
51
  async with (
52
52
  Pump(self, dispatcher, fail_silently)
53
53
  .add_middlewares(*middlewares)
54
- .draining(concurrency=concurrency, graceful=True)
54
+ .draining(concurrency=concurrency, graceful=True),
55
+ self,
55
56
  ):
56
- async with self:
57
- yield self
57
+ yield self
58
58
 
59
59
  async def send(self, message: T, /) -> None:
60
60
  await self.__producer.send(message)
cq/ext/injection.py CHANGED
@@ -1,8 +1,8 @@
1
- from collections.abc import AsyncIterator
1
+ from collections.abc import AsyncIterator, Awaitable, Callable
2
2
  from contextlib import AsyncExitStack
3
3
  from dataclasses import dataclass, field
4
4
  from enum import StrEnum
5
- from typing import Any, Awaitable, Callable
5
+ from typing import Any
6
6
 
7
7
  from injection import Module, adefine_scope, mod
8
8
  from injection.exceptions import ScopeAlreadyDefinedError
@@ -1,7 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from contextlib import AbstractAsyncContextManager, AbstractContextManager
3
4
  from dataclasses import dataclass
4
- from typing import TYPE_CHECKING, Any, AsyncContextManager, ContextManager
5
+ from typing import TYPE_CHECKING, Any
5
6
 
6
7
  if TYPE_CHECKING: # pragma: no cover
7
8
  from cq import MiddlewareResult
@@ -11,7 +12,7 @@ __all__ = ("AsyncContextManagerMiddleware", "ContextManagerMiddleware")
11
12
 
12
13
  @dataclass(repr=False, eq=False, frozen=True, slots=True)
13
14
  class AsyncContextManagerMiddleware:
14
- context: AsyncContextManager[Any]
15
+ context: AbstractAsyncContextManager[Any]
15
16
 
16
17
  async def __call__(self, /, *args: Any, **kwargs: Any) -> MiddlewareResult[Any]:
17
18
  async with self.context:
@@ -20,7 +21,7 @@ class AsyncContextManagerMiddleware:
20
21
 
21
22
  @dataclass(repr=False, eq=False, frozen=True, slots=True)
22
23
  class ContextManagerMiddleware:
23
- context: ContextManager[Any]
24
+ context: AbstractContextManager[Any]
24
25
 
25
26
  async def __call__(self, /, *args: Any, **kwargs: Any) -> MiddlewareResult[Any]:
26
27
  with self.context:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-cq
3
- Version: 0.22.0
3
+ Version: 0.22.1
4
4
  Summary: CQRS library for async Python projects.
5
5
  Project-URL: Documentation, https://python-cq.remimd.dev
6
6
  Project-URL: Repository, https://github.com/100nm/python-cq
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Classifier: Programming Language :: Python :: 3.13
20
20
  Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
21
22
  Classifier: Topic :: Software Development :: Libraries
22
23
  Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
23
24
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
@@ -80,23 +81,27 @@ from cq import CommandBus, command_handler
80
81
  from dataclasses import dataclass
81
82
  from injection import inject
82
83
 
84
+
83
85
  @dataclass
84
86
  class CreateUserCommand:
85
87
  name: str
86
88
  email: str
87
89
 
90
+
88
91
  @command_handler
89
92
  class CreateUserHandler:
90
93
  async def handle(self, command: CreateUserCommand) -> int:
91
94
  # ... persist the user, return its id
92
95
  return 42
93
96
 
97
+
94
98
  @inject
95
99
  async def main(bus: CommandBus[int]) -> None:
96
100
  command = CreateUserCommand(name="Ada", email="ada@example.com")
97
101
  user_id = await bus.dispatch(command)
98
102
  print(f"Created user {user_id}")
99
103
 
104
+
100
105
  asyncio.run(main())
101
106
  ```
102
107
 
@@ -1,12 +1,12 @@
1
- cq/__init__.py,sha256=efZeCSuvUsBJ00dVLEs3DcNd1fdPhgYhH4xkCQVpO9Y,1963
1
+ cq/__init__.py,sha256=wOVY8Yzkk_PqL2_yOb7X5AsLMYtXNf9FyWbniG5PgHY,1963
2
2
  cq/exceptions.py,sha256=lmIpWDbPPwdS9bAAKxUvampA1KKmB706wWaB2mKZyPc,111
3
3
  cq/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cq/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  cq/_core/cq.py,sha256=YDYcLMHAIlyCJ1NSm0sR_JnsVJ0wYZ1ndkUE0sArzic,2304
6
6
  cq/_core/di.py,sha256=vqHvDTvXNRH8C_we1fKMicvQ6SuGM8aedHQaMrP6Llo,3369
7
- cq/_core/handler.py,sha256=2lc5B1WS3NOm_lJakOF9aTlto5Hh9cvJl6dppYknWzs,7276
7
+ cq/_core/handler.py,sha256=gMHd5ODFZJ_Wx_cNbFSwrGpPn-oXGNLKz-xmMRub0jg,7302
8
8
  cq/_core/message.py,sha256=HpoYHstxRTWoUw_FuqDkytzyvK0Mb0U96Bz15ZEBd70,278
9
- cq/_core/middleware.py,sha256=RX_bLoqBL2p_dyCQs-jeozGVe6s7L9O4hDiwFxEprDY,3686
9
+ cq/_core/middleware.py,sha256=5IWM27nKd-ULq7M3GrBIwYIpYU7DBePfn0dvLDJ2Gh4,3702
10
10
  cq/_core/pipetools.py,sha256=o2FqEfnIaoFwfY0maxI2rg6bK4vlBJK3KdHvQL4vPk0,1583
11
11
  cq/_core/pump.py,sha256=Kxrmdex1Yf2YhbA45e7n7Whwdp9fAi_npaAND8_cSrc,1749
12
12
  cq/_core/related_events.py,sha256=vPltQdmQjnfb3eOB2lO6dxqjJEsGOjOyCNj7_2ehNAk,1389
@@ -18,15 +18,15 @@ cq/_core/dispatchers/bus.py,sha256=eOhZXZxBOFS5Emx4h7a5ulgT5hWtyQtwxTIU5RqHRGw,3
18
18
  cq/_core/dispatchers/lazy.py,sha256=byvwDZBBoTpnd40MCSTWNQ2ubyK_ib-pjxYoumqfSaY,715
19
19
  cq/_core/dispatchers/pipe.py,sha256=gdq0ihPlBgcAVSQrR0ovcFVdQhUB6Ejj6Lg5K76L2Rg,9723
20
20
  cq/_core/queues/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
- cq/_core/queues/abc.py,sha256=zXb9Nre9gaKPCbQbkUErnJGRn14UP1K7GpR_N7DFhkE,690
22
- cq/_core/queues/memory.py,sha256=VIZN3jIcnE7ij4NKhCJu6jEfvSgk5_EadtQejsxR2Lo,1811
21
+ cq/_core/queues/abc.py,sha256=XAKHNK6Ez20UWTo_WC5DysMR1h1O3c3gPvwj0TWzQQk,728
22
+ cq/_core/queues/memory.py,sha256=c_dq2UmjNblEYR4zkFczo7XS9ZNmYc_tZz4CdB3LzRo,1797
23
23
  cq/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
- cq/ext/injection.py,sha256=6up8NqcUYwMjbGdxV653Ai4Bb49OckF6vIhocwz_bjk,3113
24
+ cq/ext/injection.py,sha256=FxcShgcy7SJ1tQHHFtD9A6WgMTC_n1tM2L3EB9_kfeg,3113
25
25
  cq/middlewares/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- cq/middlewares/contextlib.py,sha256=8fXNI6Y3pOjLbDz8JRHb1KXU8cbPWksUV6qhcRCvd5s,821
26
+ cq/middlewares/contextlib.py,sha256=_kwbXteGADGuzD-o2pPoPWOeTKiXcPCNuDmpG-f-YnY,875
27
27
  cq/middlewares/exc.py,sha256=ecAMoksj6B4osySSZ9g_cBR35_tiABQdpII-Drxkz44,1604
28
28
  cq/middlewares/retry.py,sha256=L6X_Wa2TZ0IYNXmi8oexTXQyM_lkjJt5Ew4D-2VzwBY,957
29
- python_cq-0.22.0.dist-info/METADATA,sha256=XtA7nmM9n-qTSqojG1-YVSA3mGY87YTjC0ykeiYNQ90,4507
30
- python_cq-0.22.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
31
- python_cq-0.22.0.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
32
- python_cq-0.22.0.dist-info/RECORD,,
29
+ python_cq-0.22.1.dist-info/METADATA,sha256=Py9rY1o_fjUEuIpDYtuBnJfvdIxsT1UtoOsTdRwsTHo,4562
30
+ python_cq-0.22.1.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
31
+ python_cq-0.22.1.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
32
+ python_cq-0.22.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.30.1
2
+ Generator: hatchling 1.31.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any