python-injection 0.18.1__tar.gz → 0.18.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.
Files changed (29) hide show
  1. {python_injection-0.18.1 → python_injection-0.18.2}/PKG-INFO +1 -1
  2. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/module.py +16 -7
  3. {python_injection-0.18.1 → python_injection-0.18.2}/pyproject.toml +1 -1
  4. {python_injection-0.18.1 → python_injection-0.18.2}/.gitignore +0 -0
  5. {python_injection-0.18.1 → python_injection-0.18.2}/LICENSE +0 -0
  6. {python_injection-0.18.1 → python_injection-0.18.2}/README.md +0 -0
  7. {python_injection-0.18.1 → python_injection-0.18.2}/injection/__init__.py +0 -0
  8. {python_injection-0.18.1 → python_injection-0.18.2}/injection/__init__.pyi +0 -0
  9. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/__init__.py +0 -0
  10. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/common/__init__.py +0 -0
  11. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/common/asynchronous.py +0 -0
  12. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/common/event.py +0 -0
  13. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/common/invertible.py +0 -0
  14. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/common/key.py +0 -0
  15. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/common/lazy.py +0 -0
  16. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/common/type.py +0 -0
  17. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/descriptors.py +0 -0
  18. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/injectables.py +0 -0
  19. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/scope.py +0 -0
  20. {python_injection-0.18.1 → python_injection-0.18.2}/injection/_core/slots.py +0 -0
  21. {python_injection-0.18.1 → python_injection-0.18.2}/injection/entrypoint.py +0 -0
  22. {python_injection-0.18.1 → python_injection-0.18.2}/injection/exceptions.py +0 -0
  23. {python_injection-0.18.1 → python_injection-0.18.2}/injection/ext/__init__.py +0 -0
  24. {python_injection-0.18.1 → python_injection-0.18.2}/injection/ext/fastapi.py +0 -0
  25. {python_injection-0.18.1 → python_injection-0.18.2}/injection/ext/fastapi.pyi +0 -0
  26. {python_injection-0.18.1 → python_injection-0.18.2}/injection/loaders.py +0 -0
  27. {python_injection-0.18.1 → python_injection-0.18.2}/injection/py.typed +0 -0
  28. {python_injection-0.18.1 → python_injection-0.18.2}/injection/testing/__init__.py +0 -0
  29. {python_injection-0.18.1 → python_injection-0.18.2}/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.1
3
+ Version: 0.18.2
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
  """
@@ -802,8 +808,11 @@ class Module(Broker, EventListener):
802
808
  return self
803
809
 
804
810
  def unlock(self) -> Self:
805
- for broker in self.__brokers:
806
- broker.unlock()
811
+ event = UnlockCalled()
812
+
813
+ with self.dispatch(event, lock_bypass=True):
814
+ for broker in self.__brokers:
815
+ broker.unlock()
807
816
 
808
817
  return self
809
818
 
@@ -838,20 +847,20 @@ class Module(Broker, EventListener):
838
847
  self.__channel.remove_listener(listener)
839
848
  return self
840
849
 
841
- def on_event(self, event: Event, /) -> ContextManager[None] | None:
850
+ def on_event(self, event: Event, /) -> ContextManager[None]:
842
851
  self_event = ModuleEventProxy(self, event)
843
852
  return self.dispatch(self_event)
844
853
 
845
854
  @contextmanager
846
- def dispatch(self, event: Event) -> Iterator[None]:
847
- self.__check_locking()
855
+ def dispatch(self, event: Event, *, lock_bypass: bool = False) -> Iterator[None]:
856
+ if not lock_bypass:
857
+ self.__check_locking()
848
858
 
849
859
  with self.__channel.dispatch(event):
850
860
  try:
851
861
  yield
852
862
  finally:
853
- message = str(event)
854
- self.__debug(message)
863
+ self.__debug(event)
855
864
 
856
865
  def __debug(self, message: object) -> None:
857
866
  for logger in self.__loggers:
@@ -29,7 +29,7 @@ test = [
29
29
 
30
30
  [project]
31
31
  name = "python-injection"
32
- version = "0.18.1"
32
+ version = "0.18.2"
33
33
  description = "Fast and easy dependency injection framework."
34
34
  license = "MIT"
35
35
  license-files = ["LICENSE"]