77from inspect import signature as inspect_signature
88from typing import TYPE_CHECKING , Any , Protocol , Self , overload , runtime_checkable
99
10- import injection
1110from type_analyzer import MatchingTypesConfig , iter_matching_types , matching_types
1211
1312from cq ._core .common .typing import Decorator
13+ from cq ._core .di import DIAdapter , NoDI
1414
1515type HandlerType [** P , T ] = type [Handler [P , T ]]
1616type HandlerFactory [** P , T ] = Callable [..., Awaitable [Handler [P , T ]]]
@@ -126,7 +126,7 @@ def subscribe(
126126@dataclass (repr = False , eq = False , frozen = True , slots = True )
127127class HandlerDecorator [I , O ]:
128128 registry : HandlerRegistry [I , O ]
129- injection_module : injection . Module = field (default_factory = injection . mod )
129+ di : DIAdapter = field (default_factory = NoDI )
130130
131131 if TYPE_CHECKING : # pragma: no cover
132132
@@ -137,7 +137,6 @@ def __call__(
137137 / ,
138138 * ,
139139 fail_silently : bool = ...,
140- threadsafe : bool | None = ...,
141140 ) -> Decorator : ...
142141
143142 @overload
@@ -147,7 +146,6 @@ def __call__[T](
147146 / ,
148147 * ,
149148 fail_silently : bool = ...,
150- threadsafe : bool | None = ...,
151149 ) -> T : ...
152150
153151 @overload
@@ -157,7 +155,6 @@ def __call__(
157155 / ,
158156 * ,
159157 fail_silently : bool = ...,
160- threadsafe : bool | None = ...,
161158 ) -> Decorator : ...
162159
163160 def __call__ [T ](
@@ -166,7 +163,6 @@ def __call__[T](
166163 / ,
167164 * ,
168165 fail_silently : bool = False ,
169- threadsafe : bool | None = None ,
170166 ) -> Any :
171167 if (
172168 input_or_handler_type is not None
@@ -176,14 +172,12 @@ def __call__[T](
176172 return self .__decorator (
177173 input_or_handler_type ,
178174 fail_silently = fail_silently ,
179- threadsafe = threadsafe ,
180175 )
181176
182177 return partial (
183178 self .__decorator ,
184179 input_type = input_or_handler_type , # type: ignore[arg-type]
185180 fail_silently = fail_silently ,
186- threadsafe = threadsafe ,
187181 )
188182
189183 def __decorator (
@@ -193,9 +187,8 @@ def __decorator(
193187 * ,
194188 input_type : type [I ] | None = None ,
195189 fail_silently : bool = False ,
196- threadsafe : bool | None = None ,
197190 ) -> HandlerType [[I ], O ]:
198- factory = self .injection_module . make_async_factory (wrapped , threadsafe )
191+ factory = self .di . wire (wrapped )
199192 input_type = input_type or _resolve_input_type (wrapped )
200193 self .registry .subscribe (input_type , factory , wrapped , fail_silently )
201194 return wrapped
0 commit comments