python-injection 0.18.6.post0__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.
Files changed (29) hide show
  1. {python_injection-0.18.6.post0 → python_injection-0.18.8}/PKG-INFO +1 -1
  2. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/__init__.pyi +1 -0
  3. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/module.py +4 -0
  4. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/loaders.py +6 -2
  5. {python_injection-0.18.6.post0 → python_injection-0.18.8}/pyproject.toml +1 -1
  6. {python_injection-0.18.6.post0 → python_injection-0.18.8}/.gitignore +0 -0
  7. {python_injection-0.18.6.post0 → python_injection-0.18.8}/LICENSE +0 -0
  8. {python_injection-0.18.6.post0 → python_injection-0.18.8}/README.md +0 -0
  9. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/__init__.py +0 -0
  10. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/__init__.py +0 -0
  11. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/common/__init__.py +0 -0
  12. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/common/asynchronous.py +0 -0
  13. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/common/event.py +0 -0
  14. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/common/invertible.py +0 -0
  15. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/common/key.py +0 -0
  16. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/common/lazy.py +0 -0
  17. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/common/type.py +0 -0
  18. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/descriptors.py +0 -0
  19. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/injectables.py +0 -0
  20. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/scope.py +0 -0
  21. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/_core/slots.py +0 -0
  22. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/entrypoint.py +0 -0
  23. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/exceptions.py +0 -0
  24. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/ext/__init__.py +0 -0
  25. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/ext/fastapi.py +0 -0
  26. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/ext/fastapi.pyi +0 -0
  27. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/py.typed +0 -0
  28. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/testing/__init__.py +0 -0
  29. {python_injection-0.18.6.post0 → python_injection-0.18.8}/injection/testing/__init__.pyi +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-injection
3
- Version: 0.18.6.post0
3
+ Version: 0.18.8
4
4
  Summary: Fast and easy dependency injection framework.
5
5
  Project-URL: Repository, https://github.com/100nm/python-injection
6
6
  Author: remimd
@@ -320,6 +320,7 @@ class Module:
320
320
  module: Module,
321
321
  *,
322
322
  priority: Priority | PriorityStr = ...,
323
+ unlock: bool = ...,
323
324
  ) -> Iterator[Self]:
324
325
  """
325
326
  Context manager or decorator for temporary use of a module.
@@ -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:
@@ -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.unlock().init_modules(*target_modules)
171
+ module.init_modules(*target_modules)
168
172
  self.__mark_initialized(module)
169
173
 
170
174
  return module
@@ -29,7 +29,7 @@ test = [
29
29
 
30
30
  [project]
31
31
  name = "python-injection"
32
- version = "0.18.6.post0"
32
+ version = "0.18.8"
33
33
  description = "Fast and easy dependency injection framework."
34
34
  license = "MIT"
35
35
  license-files = ["LICENSE"]