python-injection 0.10.9__py3-none-any.whl → 0.10.10__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
|
|
1
1
|
from collections.abc import Callable
|
2
2
|
from types import GenericAlias
|
3
|
-
from typing import Any, ClassVar, TypeAliasType
|
3
|
+
from typing import Any, ClassVar, Self, TypeAliasType
|
4
4
|
|
5
5
|
from injection import Module, mod
|
6
6
|
from injection.exceptions import InjectionError
|
@@ -28,10 +28,11 @@ def Inject[T]( # noqa: N802
|
|
28
28
|
|
29
29
|
|
30
30
|
class InjectionDependency[T]:
|
31
|
-
__slots__ = ("__call__", "__class")
|
31
|
+
__slots__ = ("__call__", "__class", "__module")
|
32
32
|
|
33
33
|
__call__: Callable[[], T]
|
34
34
|
__class: type[T] | TypeAliasType | GenericAlias
|
35
|
+
__module: Module
|
35
36
|
|
36
37
|
__sentinel: ClassVar[object] = object()
|
37
38
|
|
@@ -39,15 +40,22 @@ class InjectionDependency[T]:
|
|
39
40
|
lazy_instance = module.get_lazy_instance(cls, default=self.__sentinel)
|
40
41
|
self.__call__ = lambda: self.__ensure(~lazy_instance)
|
41
42
|
self.__class = cls
|
43
|
+
self.__module = module
|
42
44
|
|
43
45
|
def __eq__(self, other: Any) -> bool:
|
44
46
|
if isinstance(other, type(self)):
|
45
|
-
return
|
47
|
+
return self.__key == other.__key
|
46
48
|
|
47
49
|
return NotImplemented
|
48
50
|
|
49
51
|
def __hash__(self) -> int:
|
50
|
-
return hash(
|
52
|
+
return hash(self.__key)
|
53
|
+
|
54
|
+
@property
|
55
|
+
def __key(
|
56
|
+
self,
|
57
|
+
) -> tuple[type[Self], type[T] | TypeAliasType | GenericAlias, Module]:
|
58
|
+
return type(self), self.__class, self.__module
|
51
59
|
|
52
60
|
def __ensure(self, instance: T | Any) -> T:
|
53
61
|
if instance is self.__sentinel:
|
@@ -12,11 +12,11 @@ injection/_core/module.py,sha256=c3YGhgSsZ8Cu5x-xaXHqJZEi3niSwH7HCVu6tj0IU0k,252
|
|
12
12
|
injection/exceptions.py,sha256=-5Shs7R5rctQXhpMLfcjiMBCzrtFWxC88qETUIHz57s,692
|
13
13
|
injection/integrations/__init__.py,sha256=NYLcstr4ESdLj326LlDub143z6JGM1z1pCOVWhBXK10,304
|
14
14
|
injection/integrations/blacksheep.py,sha256=yO5gLb_l4W3bNPFt-v2qWIL9R8PNon4JmOxQEHdi-5o,923
|
15
|
-
injection/integrations/fastapi.py,sha256=
|
15
|
+
injection/integrations/fastapi.py,sha256=FUX8u4yq1MNThlqv0g-e9pxh_aG6wEvcw9Yccn9aJL8,1831
|
16
16
|
injection/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
17
|
injection/testing/__init__.py,sha256=-C38gmZJwDtLDAWJhqiaosOZWQZwwFa1M34tODcrASs,747
|
18
18
|
injection/testing/__init__.pyi,sha256=6ZXbbS-9ppMdkxd03I6yBNurmR3Xw7sM_qiokibkLeY,386
|
19
19
|
injection/utils.py,sha256=gPcxGIdrGz4irbJXGTYPw33jNy8jg56u_c61eb1MBSE,1971
|
20
|
-
python_injection-0.10.
|
21
|
-
python_injection-0.10.
|
22
|
-
python_injection-0.10.
|
20
|
+
python_injection-0.10.10.dist-info/METADATA,sha256=8zGiqdSQp_K17U5o5PlArBHTT4tkkBpU8e9lQ4qLIx4,3111
|
21
|
+
python_injection-0.10.10.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
22
|
+
python_injection-0.10.10.dist-info/RECORD,,
|
File without changes
|