python-injection 0.14.1__tar.gz → 0.14.2__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.
- {python_injection-0.14.1 → python_injection-0.14.2}/PKG-INFO +1 -1
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/module.py +12 -12
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/exceptions.py +5 -1
- {python_injection-0.14.1 → python_injection-0.14.2}/pyproject.toml +1 -1
- {python_injection-0.14.1 → python_injection-0.14.2}/.gitignore +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/README.md +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/__init__.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/__init__.pyi +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/__init__.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/common/__init__.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/common/asynchronous.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/common/event.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/common/invertible.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/common/key.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/common/lazy.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/common/type.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/descriptors.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/hook.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/injectables.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/_core/scope.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/integrations/__init__.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/integrations/fastapi.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/py.typed +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/testing/__init__.py +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/testing/__init__.pyi +0 -0
- {python_injection-0.14.1 → python_injection-0.14.2}/injection/utils.py +0 -0
@@ -73,6 +73,7 @@ from injection.exceptions import (
|
|
73
73
|
ModuleLockError,
|
74
74
|
ModuleNotUsedError,
|
75
75
|
NoInjectable,
|
76
|
+
SkipInjectable,
|
76
77
|
)
|
77
78
|
|
78
79
|
"""
|
@@ -620,7 +621,7 @@ class Module(Broker, EventListener):
|
|
620
621
|
async def aget_instance(self, cls, default=None): # type: ignore[no-untyped-def]
|
621
622
|
try:
|
622
623
|
return await self.afind_instance(cls)
|
623
|
-
except KeyError:
|
624
|
+
except (KeyError, SkipInjectable):
|
624
625
|
return default
|
625
626
|
|
626
627
|
@overload
|
@@ -640,7 +641,7 @@ class Module(Broker, EventListener):
|
|
640
641
|
def get_instance(self, cls, default=None): # type: ignore[no-untyped-def]
|
641
642
|
try:
|
642
643
|
return self.find_instance(cls)
|
643
|
-
except KeyError:
|
644
|
+
except (KeyError, SkipInjectable):
|
644
645
|
return default
|
645
646
|
|
646
647
|
@overload
|
@@ -866,29 +867,28 @@ class Dependencies:
|
|
866
867
|
lazy_mapping: Lazy[Mapping[str, Injectable[Any]]]
|
867
868
|
|
868
869
|
def __iter__(self) -> Iterator[tuple[str, Any]]:
|
869
|
-
for name, injectable in self.
|
870
|
-
|
871
|
-
|
870
|
+
for name, injectable in self.items():
|
871
|
+
with suppress(SkipInjectable):
|
872
|
+
yield name, injectable.get_instance()
|
872
873
|
|
873
874
|
async def __aiter__(self) -> AsyncIterator[tuple[str, Any]]:
|
874
|
-
for name, injectable in self.
|
875
|
-
|
876
|
-
|
875
|
+
for name, injectable in self.items():
|
876
|
+
with suppress(SkipInjectable):
|
877
|
+
yield name, await injectable.aget_instance()
|
877
878
|
|
878
879
|
@property
|
879
880
|
def are_resolved(self) -> bool:
|
880
881
|
return self.lazy_mapping.is_set
|
881
882
|
|
882
|
-
@property
|
883
|
-
def mapping(self) -> Mapping[str, Injectable[Any]]:
|
884
|
-
return ~self.lazy_mapping
|
885
|
-
|
886
883
|
async def aget_arguments(self) -> dict[str, Any]:
|
887
884
|
return {key: value async for key, value in self}
|
888
885
|
|
889
886
|
def get_arguments(self) -> dict[str, Any]:
|
890
887
|
return dict(self)
|
891
888
|
|
889
|
+
def items(self) -> Iterator[tuple[str, Injectable[Any]]]:
|
890
|
+
return iter((~self.lazy_mapping).items())
|
891
|
+
|
892
892
|
@classmethod
|
893
893
|
def from_iterable(cls, iterable: Iterable[tuple[str, Injectable[Any]]]) -> Self:
|
894
894
|
lazy_mapping = Lazy(lambda: dict(iterable))
|
@@ -10,6 +10,7 @@ __all__ = (
|
|
10
10
|
"ScopeAlreadyDefinedError",
|
11
11
|
"ScopeError",
|
12
12
|
"ScopeUndefinedError",
|
13
|
+
"SkipInjectable",
|
13
14
|
)
|
14
15
|
|
15
16
|
|
@@ -30,6 +31,9 @@ class NoInjectable[T](KeyError, InjectionError):
|
|
30
31
|
return self.__class
|
31
32
|
|
32
33
|
|
34
|
+
class SkipInjectable(InjectionError): ...
|
35
|
+
|
36
|
+
|
33
37
|
class ModuleError(InjectionError): ...
|
34
38
|
|
35
39
|
|
@@ -42,7 +46,7 @@ class ModuleNotUsedError(KeyError, ModuleError): ...
|
|
42
46
|
class ScopeError(InjectionError): ...
|
43
47
|
|
44
48
|
|
45
|
-
class ScopeUndefinedError(LookupError, ScopeError): ...
|
49
|
+
class ScopeUndefinedError(LookupError, SkipInjectable, ScopeError): ...
|
46
50
|
|
47
51
|
|
48
52
|
class ScopeAlreadyDefinedError(ScopeError): ...
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|