python-cq 0.11.0__tar.gz → 0.11.1__tar.gz

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 (25) hide show
  1. {python_cq-0.11.0 → python_cq-0.11.1}/PKG-INFO +1 -1
  2. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/dispatcher/pipe.py +58 -44
  3. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/handler.py +29 -27
  4. {python_cq-0.11.0 → python_cq-0.11.1}/cq/ext/fastapi.py +1 -1
  5. {python_cq-0.11.0 → python_cq-0.11.1}/pyproject.toml +1 -1
  6. {python_cq-0.11.0 → python_cq-0.11.1}/.gitignore +0 -0
  7. {python_cq-0.11.0 → python_cq-0.11.1}/LICENSE +0 -0
  8. {python_cq-0.11.0 → python_cq-0.11.1}/README.md +0 -0
  9. {python_cq-0.11.0 → python_cq-0.11.1}/cq/__init__.py +0 -0
  10. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/__init__.py +0 -0
  11. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/dispatcher/__init__.py +0 -0
  12. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/dispatcher/base.py +0 -0
  13. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/dispatcher/bus.py +0 -0
  14. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/dispatcher/lazy.py +0 -0
  15. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/message.py +0 -0
  16. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/middleware.py +0 -0
  17. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/pipetools.py +0 -0
  18. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/related_events.py +0 -0
  19. {python_cq-0.11.0 → python_cq-0.11.1}/cq/_core/scope.py +0 -0
  20. {python_cq-0.11.0 → python_cq-0.11.1}/cq/exceptions.py +0 -0
  21. {python_cq-0.11.0 → python_cq-0.11.1}/cq/ext/__init__.py +0 -0
  22. {python_cq-0.11.0 → python_cq-0.11.1}/cq/middlewares/__init__.py +0 -0
  23. {python_cq-0.11.0 → python_cq-0.11.1}/cq/middlewares/retry.py +0 -0
  24. {python_cq-0.11.0 → python_cq-0.11.1}/cq/middlewares/scope.py +0 -0
  25. {python_cq-0.11.0 → python_cq-0.11.1}/cq/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-cq
3
- Version: 0.11.0
3
+ Version: 0.11.1
4
4
  Summary: Lightweight CQRS library for async Python projects.
5
5
  Project-URL: Repository, https://github.com/100nm/python-cq
6
6
  Author: remimd
@@ -1,7 +1,7 @@
1
1
  from collections import deque
2
2
  from collections.abc import Awaitable, Callable
3
3
  from dataclasses import dataclass, field
4
- from typing import Any, Protocol, Self, overload
4
+ from typing import TYPE_CHECKING, Any, Protocol, Self, overload
5
5
 
6
6
  from cq._core.dispatcher.base import BaseDispatcher, Dispatcher
7
7
  from cq._core.middleware import Middleware
@@ -34,23 +34,25 @@ class Pipe[I, O](BaseDispatcher[I, O]):
34
34
  self.__dispatcher = dispatcher
35
35
  self.__steps = []
36
36
 
37
- @overload
38
- def step[T](
39
- self,
40
- wrapped: PipeConverter[T, Any],
41
- /,
42
- *,
43
- dispatcher: Dispatcher[T, Any] | None = ...,
44
- ) -> PipeConverter[T, Any]: ...
45
-
46
- @overload
47
- def step[T](
48
- self,
49
- wrapped: None = ...,
50
- /,
51
- *,
52
- dispatcher: Dispatcher[T, Any] | None = ...,
53
- ) -> Callable[[PipeConverter[T, Any]], PipeConverter[T, Any]]: ...
37
+ if TYPE_CHECKING: # pragma: no cover
38
+
39
+ @overload
40
+ def step[T](
41
+ self,
42
+ wrapped: PipeConverter[T, Any],
43
+ /,
44
+ *,
45
+ dispatcher: Dispatcher[T, Any] | None = ...,
46
+ ) -> PipeConverter[T, Any]: ...
47
+
48
+ @overload
49
+ def step[T](
50
+ self,
51
+ wrapped: None = ...,
52
+ /,
53
+ *,
54
+ dispatcher: Dispatcher[T, Any] | None = ...,
55
+ ) -> Callable[[PipeConverter[T, Any]], PipeConverter[T, Any]]: ...
54
56
 
55
57
  def step[T](
56
58
  self,
@@ -114,23 +116,33 @@ class ContextPipeline[I]:
114
116
  self.__middlewares = deque()
115
117
  self.__steps = []
116
118
 
117
- @overload
118
- def __get__[O](
119
- self,
120
- instance: O,
121
- owner: type[O] | None = ...,
122
- ) -> Dispatcher[I, O]: ...
119
+ if TYPE_CHECKING: # pragma: no cover
120
+
121
+ @overload
122
+ def __get__[O](self, instance: None, owner: type[O], /) -> Dispatcher[I, O]: ...
123
123
 
124
- @overload
125
- def __get__(self, instance: None = ..., owner: type | None = ...) -> Self: ...
124
+ @overload
125
+ def __get__[O](
126
+ self,
127
+ instance: O,
128
+ owner: type[O] | None = ...,
129
+ /,
130
+ ) -> Dispatcher[I, O]: ...
131
+
132
+ @overload
133
+ def __get__(self, instance: None = ..., owner: None = ..., /) -> Self: ...
126
134
 
127
135
  def __get__[O](
128
136
  self,
129
137
  instance: O | None = None,
130
138
  owner: type[O] | None = None,
139
+ /,
131
140
  ) -> Self | Dispatcher[I, O]:
132
141
  if instance is None:
133
- return self
142
+ if owner is None:
143
+ return self
144
+
145
+ instance = owner()
134
146
 
135
147
  pipeline = self.__new_pipeline(instance, owner)
136
148
  return BoundContextPipeline(instance, pipeline)
@@ -139,23 +151,25 @@ class ContextPipeline[I]:
139
151
  self.__middlewares.extendleft(reversed(middlewares))
140
152
  return self
141
153
 
142
- @overload
143
- def step[T](
144
- self,
145
- wrapped: PipeConverterMethod[T, Any],
146
- /,
147
- *,
148
- dispatcher: Dispatcher[T, Any] | None = ...,
149
- ) -> PipeConverterMethod[T, Any]: ...
150
-
151
- @overload
152
- def step[T](
153
- self,
154
- wrapped: None = ...,
155
- /,
156
- *,
157
- dispatcher: Dispatcher[T, Any] | None = ...,
158
- ) -> Callable[[PipeConverterMethod[T, Any]], PipeConverterMethod[T, Any]]: ...
154
+ if TYPE_CHECKING: # pragma: no cover
155
+
156
+ @overload
157
+ def step[T](
158
+ self,
159
+ wrapped: PipeConverterMethod[T, Any],
160
+ /,
161
+ *,
162
+ dispatcher: Dispatcher[T, Any] | None = ...,
163
+ ) -> PipeConverterMethod[T, Any]: ...
164
+
165
+ @overload
166
+ def step[T](
167
+ self,
168
+ wrapped: None = ...,
169
+ /,
170
+ *,
171
+ dispatcher: Dispatcher[T, Any] | None = ...,
172
+ ) -> Callable[[PipeConverterMethod[T, Any]], PipeConverterMethod[T, Any]]: ...
159
173
 
160
174
  def step[T](
161
175
  self,
@@ -5,7 +5,7 @@ from dataclasses import dataclass, field
5
5
  from functools import partial
6
6
  from inspect import Parameter, getmro, isclass
7
7
  from inspect import signature as inspect_signature
8
- from typing import Any, Protocol, Self, overload, runtime_checkable
8
+ from typing import TYPE_CHECKING, Any, Protocol, Self, overload, runtime_checkable
9
9
 
10
10
  import injection
11
11
 
@@ -89,32 +89,34 @@ class HandlerDecorator[I, O]:
89
89
  manager: HandlerManager[I, O]
90
90
  injection_module: injection.Module = field(default_factory=injection.mod)
91
91
 
92
- @overload
93
- def __call__(
94
- self,
95
- input_or_handler_type: type[I],
96
- /,
97
- *,
98
- threadsafe: bool | None = ...,
99
- ) -> Callable[[HandlerType[[I], O]], HandlerType[[I], O]]: ...
100
-
101
- @overload
102
- def __call__(
103
- self,
104
- input_or_handler_type: HandlerType[[I], O],
105
- /,
106
- *,
107
- threadsafe: bool | None = ...,
108
- ) -> HandlerType[[I], O]: ...
109
-
110
- @overload
111
- def __call__(
112
- self,
113
- input_or_handler_type: None = ...,
114
- /,
115
- *,
116
- threadsafe: bool | None = ...,
117
- ) -> Callable[[HandlerType[[I], O]], HandlerType[[I], O]]: ...
92
+ if TYPE_CHECKING: # pragma: no cover
93
+
94
+ @overload
95
+ def __call__(
96
+ self,
97
+ input_or_handler_type: type[I],
98
+ /,
99
+ *,
100
+ threadsafe: bool | None = ...,
101
+ ) -> Callable[[HandlerType[[I], O]], HandlerType[[I], O]]: ...
102
+
103
+ @overload
104
+ def __call__(
105
+ self,
106
+ input_or_handler_type: HandlerType[[I], O],
107
+ /,
108
+ *,
109
+ threadsafe: bool | None = ...,
110
+ ) -> HandlerType[[I], O]: ...
111
+
112
+ @overload
113
+ def __call__(
114
+ self,
115
+ input_or_handler_type: None = ...,
116
+ /,
117
+ *,
118
+ threadsafe: bool | None = ...,
119
+ ) -> Callable[[HandlerType[[I], O]], HandlerType[[I], O]]: ...
118
120
 
119
121
  def __call__(
120
122
  self,
@@ -53,7 +53,7 @@ async def new_deferred_query_bus[T](
53
53
  return FastAPIDeferredDispatcher(background_tasks, query_bus)
54
54
 
55
55
 
56
- if TYPE_CHECKING:
56
+ if TYPE_CHECKING: # pragma: no cover
57
57
  type DeferredCommandBus = DeferredDispatcher[Command]
58
58
  type DeferredEventBus = DeferredDispatcher[Event]
59
59
  type DeferredQueryBus = DeferredDispatcher[Query]
@@ -23,7 +23,7 @@ test = [
23
23
 
24
24
  [project]
25
25
  name = "python-cq"
26
- version = "0.11.0"
26
+ version = "0.11.1"
27
27
  description = "Lightweight CQRS library for async Python projects."
28
28
  license = "MIT"
29
29
  license-files = ["LICENSE"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes