python-injection 0.19.0__py3-none-any.whl → 0.19.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.
injection/__init__.pyi CHANGED
@@ -5,6 +5,7 @@ from enum import Enum
5
5
  from logging import Logger
6
6
  from typing import Any, Final, Protocol, Self, final, overload, runtime_checkable
7
7
 
8
+ from ._core.asfunction import AsFunctionWrappedType as _AsFunctionWrappedType
8
9
  from ._core.common.invertible import Invertible as _Invertible
9
10
  from ._core.common.type import InputType as _InputType
10
11
  from ._core.common.type import TypeInfo as _TypeInfo
@@ -32,7 +33,7 @@ singleton = __MODULE.singleton
32
33
 
33
34
  @overload
34
35
  def asfunction[**P, T](
35
- wrapped: type[Callable[P, T]],
36
+ wrapped: _AsFunctionWrappedType[P, T],
36
37
  /,
37
38
  *,
38
39
  module: Module = ...,
@@ -45,7 +46,7 @@ def asfunction[**P, T](
45
46
  *,
46
47
  module: Module = ...,
47
48
  threadsafe: bool | None = ...,
48
- ) -> Callable[[type[Callable[P, T]]], Callable[P, T]]: ...
49
+ ) -> Callable[[_AsFunctionWrappedType[P, T]], Callable[P, T]]: ...
49
50
  @asynccontextmanager
50
51
  def adefine_scope(
51
52
  name: str,
@@ -1,14 +1,26 @@
1
+ from abc import abstractmethod
1
2
  from collections.abc import Callable
2
3
  from functools import wraps
3
4
  from inspect import iscoroutinefunction
4
- from typing import Any
5
+ from typing import Any, Protocol, runtime_checkable
5
6
 
6
7
  from injection._core.common.asynchronous import Caller
7
8
  from injection._core.module import Module, mod
8
9
 
10
+ type AsFunctionWrappedType[**P, T] = type[_Callable[P, T]]
11
+
12
+
13
+ @runtime_checkable
14
+ class _Callable[**P, T](Protocol):
15
+ __slots__ = ()
16
+
17
+ @abstractmethod
18
+ def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T:
19
+ raise NotImplementedError
20
+
9
21
 
10
22
  def asfunction[**P, T](
11
- wrapped: type[Callable[P, T]] | None = None,
23
+ wrapped: AsFunctionWrappedType[P, T] | None = None,
12
24
  /,
13
25
  *,
14
26
  module: Module | None = None,
@@ -16,7 +28,7 @@ def asfunction[**P, T](
16
28
  ) -> Any:
17
29
  module = module or mod()
18
30
 
19
- def decorator(wp: type[Callable[P, T]]) -> Callable[P, T]:
31
+ def decorator(wp: AsFunctionWrappedType[P, T]) -> Callable[P, T]:
20
32
  get_method = wp.__call__.__get__
21
33
  method = get_method(NotImplemented)
22
34
  factory: Caller[..., Callable[P, T]] = module.make_injected_function(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-injection
3
- Version: 0.19.0
3
+ Version: 0.19.1
4
4
  Summary: Fast and easy dependency injection framework.
5
5
  Project-URL: Repository, https://github.com/100nm/python-injection
6
6
  Author: remimd
@@ -1,11 +1,11 @@
1
1
  injection/__init__.py,sha256=iJm0BbyGZw-Qr5e8d2C3n8-7FiVD-sy4LU_i_n3AgHY,1318
2
- injection/__init__.pyi,sha256=EM22sEyb69AeZ0mOPwQpbZKD79tEShsGBoDLz9lyxKg,11472
2
+ injection/__init__.pyi,sha256=2ndBULZyjN0SnyRml2gba9OOsTY0BhR3STEyvv1aZOA,11566
3
3
  injection/entrypoint.py,sha256=NIILL_w3z2JKyn7S9XXwE0JtH2icuDWnAVpUY1fAMf8,4805
4
4
  injection/exceptions.py,sha256=v57yMujiq6H_zwwn30A8UYEZX9R9k-bY8FnsdaimPM4,1025
5
5
  injection/loaders.py,sha256=gKlJfe9nXCuB8r6j0RF9_2FHC6YplM8GQYsgRqyxYw8,7257
6
6
  injection/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  injection/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- injection/_core/asfunction.py,sha256=jgFtF22n3Fz50pdXbaCbizZxTX3oRgXWSTh-U9m0kqI,1390
8
+ injection/_core/asfunction.py,sha256=oVDJcM8buR1OnKJPDOfQ61bbrKVEPzfgtE_H74O1HN4,1718
9
9
  injection/_core/descriptors.py,sha256=1OX6JnM8Ux14vW1JSW3FzPgKc2VMTKqJUYBGT3Ypafg,800
10
10
  injection/_core/injectables.py,sha256=fxhiGv7qTCbUunhhd6a3ahosFmgznUFsEvqlwxi4gS4,6098
11
11
  injection/_core/module.py,sha256=T9zvSOjMaPZiC_DCV7BIKOqCrmAHcYcleqgNro0MBgU,32624
@@ -24,7 +24,7 @@ injection/ext/fastapi.py,sha256=fiy3-mZIIwGcql3Y5ekFX8_7hALzqXP5u40qbtNE73o,1441
24
24
  injection/ext/fastapi.pyi,sha256=HLs7mfruIEFRrN_Xf8oCvSa4qwHWfwm6HHU_KMedXkE,185
25
25
  injection/testing/__init__.py,sha256=bJ7WXBXrw4rHc91AFVFnOwFLWOlpvX9Oh2SnRQ_NESo,919
26
26
  injection/testing/__init__.pyi,sha256=raGsGlxwbz3jkzJwA_5oCIE1emWINjT2UuwzbnqRb-0,577
27
- python_injection-0.19.0.dist-info/METADATA,sha256=1MtpUw2NSEhD1meQOXkMIKGq1WA69MwrrWrIi-PK1Gw,4301
28
- python_injection-0.19.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
- python_injection-0.19.0.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
30
- python_injection-0.19.0.dist-info/RECORD,,
27
+ python_injection-0.19.1.dist-info/METADATA,sha256=5skunJb1mk9ovTHiGRielQzeImyZOTRDcd4HLg6EaO0,4301
28
+ python_injection-0.19.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
+ python_injection-0.19.1.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
30
+ python_injection-0.19.1.dist-info/RECORD,,