python-injection 0.18.4__tar.gz → 0.18.5__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.4 → python_injection-0.18.5}/PKG-INFO +1 -1
  2. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/module.py +19 -8
  3. {python_injection-0.18.4 → python_injection-0.18.5}/pyproject.toml +1 -1
  4. {python_injection-0.18.4 → python_injection-0.18.5}/.gitignore +0 -0
  5. {python_injection-0.18.4 → python_injection-0.18.5}/LICENSE +0 -0
  6. {python_injection-0.18.4 → python_injection-0.18.5}/README.md +0 -0
  7. {python_injection-0.18.4 → python_injection-0.18.5}/injection/__init__.py +0 -0
  8. {python_injection-0.18.4 → python_injection-0.18.5}/injection/__init__.pyi +0 -0
  9. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/__init__.py +0 -0
  10. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/common/__init__.py +0 -0
  11. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/common/asynchronous.py +0 -0
  12. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/common/event.py +0 -0
  13. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/common/invertible.py +0 -0
  14. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/common/key.py +0 -0
  15. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/common/lazy.py +0 -0
  16. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/common/type.py +0 -0
  17. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/descriptors.py +0 -0
  18. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/injectables.py +0 -0
  19. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/scope.py +0 -0
  20. {python_injection-0.18.4 → python_injection-0.18.5}/injection/_core/slots.py +0 -0
  21. {python_injection-0.18.4 → python_injection-0.18.5}/injection/entrypoint.py +0 -0
  22. {python_injection-0.18.4 → python_injection-0.18.5}/injection/exceptions.py +0 -0
  23. {python_injection-0.18.4 → python_injection-0.18.5}/injection/ext/__init__.py +0 -0
  24. {python_injection-0.18.4 → python_injection-0.18.5}/injection/ext/fastapi.py +0 -0
  25. {python_injection-0.18.4 → python_injection-0.18.5}/injection/ext/fastapi.pyi +0 -0
  26. {python_injection-0.18.4 → python_injection-0.18.5}/injection/loaders.py +0 -0
  27. {python_injection-0.18.4 → python_injection-0.18.5}/injection/py.typed +0 -0
  28. {python_injection-0.18.4 → python_injection-0.18.5}/injection/testing/__init__.py +0 -0
  29. {python_injection-0.18.4 → python_injection-0.18.5}/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.4
3
+ Version: 0.18.5
4
4
  Summary: Fast and easy dependency injection framework.
5
5
  Project-URL: Repository, https://github.com/100nm/python-injection
6
6
  Author: remimd
@@ -156,6 +156,12 @@ class ModulePriorityUpdated(ModuleEvent):
156
156
  )
157
157
 
158
158
 
159
+ @dataclass(frozen=True, slots=True)
160
+ class UnlockCalled(Event):
161
+ def __str__(self) -> str:
162
+ return "An `unlock` method has been called."
163
+
164
+
159
165
  """
160
166
  Broker
161
167
  """
@@ -179,7 +185,7 @@ class Broker(Protocol):
179
185
  raise NotImplementedError
180
186
 
181
187
  @abstractmethod
182
- def unlock(self) -> Self:
188
+ def unsafe_unlocking(self) -> None:
183
189
  raise NotImplementedError
184
190
 
185
191
  @abstractmethod
@@ -289,12 +295,10 @@ class Locator(Broker):
289
295
 
290
296
  return self
291
297
 
292
- def unlock(self) -> Self:
298
+ def unsafe_unlocking(self) -> None:
293
299
  for injectable in self.__injectables:
294
300
  injectable.unlock()
295
301
 
296
- return self
297
-
298
302
  async def all_ready(self) -> None:
299
303
  for injectable in self.__injectables:
300
304
  if injectable.is_locked:
@@ -802,11 +806,17 @@ class Module(Broker, EventListener):
802
806
  return self
803
807
 
804
808
  def unlock(self) -> Self:
805
- for broker in self.__brokers:
806
- broker.unlock()
809
+ event = UnlockCalled()
810
+
811
+ with self.dispatch(event, lock_bypass=True):
812
+ self.unsafe_unlocking()
807
813
 
808
814
  return self
809
815
 
816
+ def unsafe_unlocking(self) -> None:
817
+ for broker in self.__brokers:
818
+ broker.unsafe_unlocking()
819
+
810
820
  def load_profile(self, *names: str) -> ContextManager[Self]:
811
821
  modules = (self.from_name(name) for name in names)
812
822
  self.unlock().init_modules(*modules)
@@ -839,8 +849,9 @@ class Module(Broker, EventListener):
839
849
  return self.dispatch(self_event)
840
850
 
841
851
  @contextmanager
842
- def dispatch(self, event: Event) -> Iterator[None]:
843
- self.__check_locking()
852
+ def dispatch(self, event: Event, *, lock_bypass: bool = False) -> Iterator[None]:
853
+ if not lock_bypass:
854
+ self.__check_locking()
844
855
 
845
856
  with self.__channel.dispatch(event):
846
857
  try:
@@ -29,7 +29,7 @@ test = [
29
29
 
30
30
  [project]
31
31
  name = "python-injection"
32
- version = "0.18.4"
32
+ version = "0.18.5"
33
33
  description = "Fast and easy dependency injection framework."
34
34
  license = "MIT"
35
35
  license-files = ["LICENSE"]