python-injection 0.18.7__tar.gz → 0.18.8__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.18.7 → python_injection-0.18.8}/PKG-INFO +1 -1
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/__init__.pyi +1 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/module.py +4 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/entrypoint.py +1 -3
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/loaders.py +6 -2
- {python_injection-0.18.7 → python_injection-0.18.8}/pyproject.toml +1 -1
- {python_injection-0.18.7 → python_injection-0.18.8}/.gitignore +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/LICENSE +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/README.md +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/__init__.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/__init__.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/common/__init__.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/common/asynchronous.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/common/event.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/common/invertible.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/common/key.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/common/lazy.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/common/type.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/descriptors.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/injectables.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/scope.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/_core/slots.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/exceptions.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/ext/__init__.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/ext/fastapi.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/ext/fastapi.pyi +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/py.typed +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/testing/__init__.py +0 -0
- {python_injection-0.18.7 → python_injection-0.18.8}/injection/testing/__init__.pyi +0 -0
@@ -788,12 +788,16 @@ class Module(Broker, EventListener):
|
|
788
788
|
module: Module,
|
789
789
|
*,
|
790
790
|
priority: Priority | PriorityStr = Priority.get_default(),
|
791
|
+
unlock: bool = False,
|
791
792
|
) -> Iterator[Self]:
|
792
793
|
self.use(module, priority=priority)
|
793
794
|
|
794
795
|
try:
|
795
796
|
yield self
|
796
797
|
finally:
|
798
|
+
if unlock:
|
799
|
+
self.unlock()
|
800
|
+
|
797
801
|
self.stop_using(module)
|
798
802
|
|
799
803
|
def change_priority(self, module: Module, priority: Priority | PriorityStr) -> Self:
|
@@ -153,9 +153,7 @@ class Entrypoint[**P, T]:
|
|
153
153
|
setup_method = profile_loader.module.make_injected_function(setup_method)
|
154
154
|
|
155
155
|
def decorator(function: Callable[P, T]) -> Callable[P, _T]:
|
156
|
-
|
157
|
-
profile_loader.init()
|
158
|
-
|
156
|
+
profile_loader.init()
|
159
157
|
self = cls(function, profile_loader)
|
160
158
|
return MethodType(setup_method, self)().function
|
161
159
|
|
@@ -145,6 +145,10 @@ class ProfileLoader:
|
|
145
145
|
module: Module = field(default_factory=mod, kw_only=True)
|
146
146
|
__initialized_modules: set[str] = field(default_factory=set, init=False)
|
147
147
|
|
148
|
+
@property
|
149
|
+
def __is_empty(self) -> bool:
|
150
|
+
return not self.module_subsets
|
151
|
+
|
148
152
|
def init(self) -> Self:
|
149
153
|
self.__init_subsets_for(self.module)
|
150
154
|
return self
|
@@ -159,12 +163,12 @@ class ProfileLoader:
|
|
159
163
|
self.module.unlock().stop_using(mod(name))
|
160
164
|
|
161
165
|
def __init_subsets_for(self, module: Module) -> Module:
|
162
|
-
if not self.__is_initialized(module):
|
166
|
+
if not self.__is_empty and not self.__is_initialized(module):
|
163
167
|
target_modules = tuple(
|
164
168
|
self.__init_subsets_for(mod(name))
|
165
169
|
for name in self.module_subsets.get(module.name, ())
|
166
170
|
)
|
167
|
-
module.
|
171
|
+
module.init_modules(*target_modules)
|
168
172
|
self.__mark_initialized(module)
|
169
173
|
|
170
174
|
return module
|
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
|
File without changes
|