Skip to content

Commit 18c2b3c

Browse files
authored
fix: 🐛 Inspection errors with mypy
1 parent 33aeeaf commit 18c2b3c

File tree

1 file changed

+63
-34
lines changed

1 file changed

+63
-34
lines changed

injection/__init__.pyi

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ class Module:
145145
threadsafe: bool | None = ...,
146146
) -> type[T]: ...
147147
@overload
148-
def inject[**P, T](
148+
def inject(
149149
self,
150150
wrapped: None = ...,
151151
/,
152152
*,
153153
threadsafe: bool | None = ...,
154-
) -> _Decorator[Callable[P, T]] | _Decorator[type[T]]: ...
154+
) -> _Decorator[Callable[..., Any] | type]: ...
155155
@overload
156156
def injectable[**P, T](
157157
self,
@@ -192,20 +192,27 @@ class Module:
192192
mode: Mode | ModeStr = ...,
193193
) -> type[T]: ...
194194
@overload
195-
def injectable[**P, T](
195+
def injectable[T](
196196
self,
197197
wrapped: None = ...,
198198
/,
199199
*,
200200
cls: _InjectableFactory[T] = ...,
201201
inject: bool = ...,
202-
on: _TypeInfo[T] = ...,
202+
on: _TypeInfo[T],
203203
mode: Mode | ModeStr = ...,
204-
) -> (
205-
_Decorator[Callable[P, T]]
206-
| _Decorator[Callable[P, Awaitable[T]]]
207-
| _Decorator[type[T]]
208-
): ...
204+
) -> _Decorator[Callable[..., T] | Callable[..., Awaitable[T]] | type[T]]: ...
205+
@overload
206+
def injectable(
207+
self,
208+
wrapped: None = ...,
209+
/,
210+
*,
211+
cls: _InjectableFactory[Any] = ...,
212+
inject: bool = ...,
213+
on: tuple[()] = ...,
214+
mode: Mode | ModeStr = ...,
215+
) -> _Decorator[Callable[..., Any] | type]: ...
209216
@overload
210217
def singleton[**P, T](
211218
self,
@@ -243,40 +250,57 @@ class Module:
243250
mode: Mode | ModeStr = ...,
244251
) -> type[T]: ...
245252
@overload
246-
def singleton[**P, T](
253+
def singleton[T](
247254
self,
248255
wrapped: None = ...,
249256
/,
250257
*,
251258
inject: bool = ...,
252-
on: _TypeInfo[T] = ...,
259+
on: _TypeInfo[T],
260+
mode: Mode | ModeStr = ...,
261+
) -> _Decorator[Callable[..., T] | Callable[..., Awaitable[T]] | type[T]]: ...
262+
@overload
263+
def singleton(
264+
self,
265+
wrapped: None = ...,
266+
/,
267+
*,
268+
inject: bool = ...,
269+
on: tuple[()] = ...,
253270
mode: Mode | ModeStr = ...,
254-
) -> (
255-
_Decorator[Callable[P, T]]
256-
| _Decorator[Callable[P, Awaitable[T]]]
257-
| _Decorator[type[T]]
258-
): ...
259-
def scoped[**P, T](
271+
) -> _Decorator[Callable[..., Any] | type]: ...
272+
@overload
273+
def scoped[T](
260274
self,
261275
scope_name: str,
262276
/,
263277
*,
264278
inject: bool = ...,
265-
on: _TypeInfo[T] = (),
279+
on: _TypeInfo[T],
266280
mode: Mode | ModeStr = ...,
267-
) -> (
268-
_Decorator[Callable[P, T]]
269-
| _Decorator[Callable[P, Awaitable[T]]]
270-
| _Decorator[Callable[P, AsyncIterator[T]]]
271-
| _Decorator[Callable[P, Iterator[T]]]
272-
| _Decorator[type[T]]
273-
):
281+
) -> _Decorator[
282+
Callable[..., T]
283+
| Callable[..., Awaitable[T]]
284+
| Callable[..., AsyncIterator[T]]
285+
| Callable[..., Iterator[T]]
286+
| type[T]
287+
]:
274288
"""
275289
Decorator applicable to a class or function or generator function. It is used
276290
to indicate how the scoped instance will be constructed. At injection time, the
277291
injected instance is retrieved from the scope.
278292
"""
279293

294+
@overload
295+
def scoped(
296+
self,
297+
scope_name: str,
298+
/,
299+
*,
300+
inject: bool = ...,
301+
on: tuple[()] = ...,
302+
mode: Mode | ModeStr = ...,
303+
) -> _Decorator[Callable[..., Any] | type]: ...
280304
@overload
281305
def should_be_injectable[T](self, wrapped: type[T], /) -> type[T]:
282306
"""
@@ -286,11 +310,11 @@ class Module:
286310
"""
287311

288312
@overload
289-
def should_be_injectable[T](
313+
def should_be_injectable(
290314
self,
291315
wrapped: None = ...,
292316
/,
293-
) -> _Decorator[type[T]]: ...
317+
) -> _Decorator[type]: ...
294318
@overload
295319
def constant[**P, T](
296320
self,
@@ -325,18 +349,23 @@ class Module:
325349
mode: Mode | ModeStr = ...,
326350
) -> type[T]: ...
327351
@overload
328-
def constant[**P, T](
352+
def constant[T](
329353
self,
330354
wrapped: None = ...,
331355
/,
332356
*,
333-
on: _TypeInfo[T] = ...,
357+
on: _TypeInfo[T],
358+
mode: Mode | ModeStr = ...,
359+
) -> _Decorator[Callable[..., T] | Callable[..., Awaitable[T]] | type[T]]: ...
360+
@overload
361+
def constant(
362+
self,
363+
wrapped: None = ...,
364+
/,
365+
*,
366+
on: tuple[()] = ...,
334367
mode: Mode | ModeStr = ...,
335-
) -> (
336-
_Decorator[Callable[P, T]]
337-
| _Decorator[Callable[P, Awaitable[T]]]
338-
| _Decorator[type[T]]
339-
): ...
368+
) -> _Decorator[Callable[..., Any] | type]: ...
340369
def set_constant[T](
341370
self,
342371
instance: T,

0 commit comments

Comments
 (0)