python-injection 0.18.9__tar.gz → 0.18.10__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.9 → python_injection-0.18.10}/PKG-INFO +1 -1
  2. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/scope.py +9 -7
  3. {python_injection-0.18.9 → python_injection-0.18.10}/pyproject.toml +1 -1
  4. {python_injection-0.18.9 → python_injection-0.18.10}/.gitignore +0 -0
  5. {python_injection-0.18.9 → python_injection-0.18.10}/LICENSE +0 -0
  6. {python_injection-0.18.9 → python_injection-0.18.10}/README.md +0 -0
  7. {python_injection-0.18.9 → python_injection-0.18.10}/injection/__init__.py +0 -0
  8. {python_injection-0.18.9 → python_injection-0.18.10}/injection/__init__.pyi +0 -0
  9. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/__init__.py +0 -0
  10. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/common/__init__.py +0 -0
  11. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/common/asynchronous.py +0 -0
  12. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/common/event.py +0 -0
  13. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/common/invertible.py +0 -0
  14. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/common/key.py +0 -0
  15. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/common/lazy.py +0 -0
  16. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/common/type.py +0 -0
  17. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/descriptors.py +0 -0
  18. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/injectables.py +0 -0
  19. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/module.py +0 -0
  20. {python_injection-0.18.9 → python_injection-0.18.10}/injection/_core/slots.py +0 -0
  21. {python_injection-0.18.9 → python_injection-0.18.10}/injection/entrypoint.py +0 -0
  22. {python_injection-0.18.9 → python_injection-0.18.10}/injection/exceptions.py +0 -0
  23. {python_injection-0.18.9 → python_injection-0.18.10}/injection/ext/__init__.py +0 -0
  24. {python_injection-0.18.9 → python_injection-0.18.10}/injection/ext/fastapi.py +0 -0
  25. {python_injection-0.18.9 → python_injection-0.18.10}/injection/ext/fastapi.pyi +0 -0
  26. {python_injection-0.18.9 → python_injection-0.18.10}/injection/loaders.py +0 -0
  27. {python_injection-0.18.9 → python_injection-0.18.10}/injection/py.typed +0 -0
  28. {python_injection-0.18.9 → python_injection-0.18.10}/injection/testing/__init__.py +0 -0
  29. {python_injection-0.18.9 → python_injection-0.18.10}/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.9
3
+ Version: 0.18.10
4
4
  Summary: Fast and easy dependency injection framework.
5
5
  Project-URL: Repository, https://github.com/100nm/python-injection
6
6
  Author: remimd
@@ -223,11 +223,10 @@ def _bind_scope(
223
223
  )
224
224
 
225
225
  stack = ExitStack()
226
- binder = states[name].bind(scope)
227
- stack.enter_context(binder)
226
+ stack.enter_context(states[name].bind(scope))
228
227
 
229
228
  try:
230
- yield _UserScope(scope)
229
+ yield _UserScope(scope, lock)
231
230
 
232
231
  finally:
233
232
  with lock:
@@ -325,6 +324,7 @@ class ScopeFacade(Protocol):
325
324
  @dataclass(repr=False, frozen=True, slots=True)
326
325
  class _UserScope(ScopeFacade):
327
326
  scope: Scope
327
+ lock: ContextManager[Any]
328
328
 
329
329
  def set_slot[T](self, key: SlotKey[T], value: T) -> Self:
330
330
  return self.slot_map({key: value})
@@ -332,9 +332,11 @@ class _UserScope(ScopeFacade):
332
332
  def slot_map(self, mapping: Mapping[SlotKey[Any], Any], /) -> Self:
333
333
  cache = self.scope.cache
334
334
 
335
- for slot_key in mapping:
336
- if slot_key in cache:
337
- raise InjectionError("Slot already set.")
335
+ with self.lock:
336
+ for slot_key in mapping:
337
+ if slot_key in cache:
338
+ raise InjectionError("Slot already set.")
339
+
340
+ cache.update(mapping)
338
341
 
339
- cache.update(mapping)
340
342
  return self
@@ -29,7 +29,7 @@ test = [
29
29
 
30
30
  [project]
31
31
  name = "python-injection"
32
- version = "0.18.9"
32
+ version = "0.18.10"
33
33
  description = "Fast and easy dependency injection framework."
34
34
  license = "MIT"
35
35
  license-files = ["LICENSE"]