python-injection 0.18.9__py3-none-any.whl → 0.18.10__py3-none-any.whl

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.
injection/_core/scope.py CHANGED
@@ -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
@@ -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
@@ -8,7 +8,7 @@ injection/_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  injection/_core/descriptors.py,sha256=jH0pyIlPurMmU4yXr-HKS_7BJ-9d0XUvEx4pQre3QeI,704
9
9
  injection/_core/injectables.py,sha256=Rg1nxDkbcpeX4ELohrNVMguPhN36SNQuD0JKfyfL6bI,6192
10
10
  injection/_core/module.py,sha256=4WqrDti98A5CrIWaHlld1GYYm4K-8XkKltchJoyXUTU,32016
11
- injection/_core/scope.py,sha256=6EKhwbXMwx8ZvqQ5TKzfVtg_JWHhZj_qkHACiDqs6h0,8731
11
+ injection/_core/scope.py,sha256=SEXO1CBJc4EzITi6oMotnNqIrRpLzabjNaBPD18_KHA,8784
12
12
  injection/_core/slots.py,sha256=g9TG6CbqRzCsjg01iPyfRtTTUCJnnJOwcj9mJabH0dc,37
13
13
  injection/_core/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  injection/_core/common/asynchronous.py,sha256=QeS2Lc4gEBFvTA_snOWfme5mTL4BFZWqZ8EzJwOdVos,1816
@@ -22,7 +22,7 @@ injection/ext/fastapi.py,sha256=layUUer5IWiZX6Mmx1_RCYDLNCtEHtpya5ZL6TTBOkY,968
22
22
  injection/ext/fastapi.pyi,sha256=8OZEUjHFB9n7QXv_dtXdDuXW-r2huQEFsJ03gJOOvwQ,125
23
23
  injection/testing/__init__.py,sha256=bJ7WXBXrw4rHc91AFVFnOwFLWOlpvX9Oh2SnRQ_NESo,919
24
24
  injection/testing/__init__.pyi,sha256=raGsGlxwbz3jkzJwA_5oCIE1emWINjT2UuwzbnqRb-0,577
25
- python_injection-0.18.9.dist-info/METADATA,sha256=ReK9ZuwTqgR5Pv9RI-o2p-j33O2GgGz0Fq_WUpxBkZU,3397
26
- python_injection-0.18.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- python_injection-0.18.9.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
28
- python_injection-0.18.9.dist-info/RECORD,,
25
+ python_injection-0.18.10.dist-info/METADATA,sha256=65dTrGn29gCNAUxlwj-Kq10XuQ2xtVLzsv9xdrPaVYQ,3398
26
+ python_injection-0.18.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ python_injection-0.18.10.dist-info/licenses/LICENSE,sha256=oC77BOa9kaaQni5rW-Z-ytz3E5h4EVg248BHg9UFgyg,1063
28
+ python_injection-0.18.10.dist-info/RECORD,,