python-injection 0.26.0__tar.gz → 0.26.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 (31) hide show
  1. {python_injection-0.26.0 → python_injection-0.26.2}/PKG-INFO +2 -2
  2. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/scope.py +22 -6
  3. {python_injection-0.26.0 → python_injection-0.26.2}/pyproject.toml +2 -2
  4. {python_injection-0.26.0 → python_injection-0.26.2}/.gitignore +0 -0
  5. {python_injection-0.26.0 → python_injection-0.26.2}/LICENSE +0 -0
  6. {python_injection-0.26.0 → python_injection-0.26.2}/docs/index.md +0 -0
  7. {python_injection-0.26.0 → python_injection-0.26.2}/injection/__init__.py +0 -0
  8. {python_injection-0.26.0 → python_injection-0.26.2}/injection/__init__.pyi +0 -0
  9. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/__init__.py +0 -0
  10. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/asfunction.py +0 -0
  11. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/common/__init__.py +0 -0
  12. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/common/asynchronous.py +0 -0
  13. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/common/event.py +0 -0
  14. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/common/invertible.py +0 -0
  15. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/common/lazy.py +0 -0
  16. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/common/threading.py +0 -0
  17. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/common/type.py +0 -0
  18. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/descriptors.py +0 -0
  19. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/injectables.py +0 -0
  20. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/locator.py +0 -0
  21. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/module.py +0 -0
  22. {python_injection-0.26.0 → python_injection-0.26.2}/injection/_core/slots.py +0 -0
  23. {python_injection-0.26.0 → python_injection-0.26.2}/injection/entrypoint.py +0 -0
  24. {python_injection-0.26.0 → python_injection-0.26.2}/injection/exceptions.py +0 -0
  25. {python_injection-0.26.0 → python_injection-0.26.2}/injection/ext/__init__.py +0 -0
  26. {python_injection-0.26.0 → python_injection-0.26.2}/injection/ext/fastapi.py +0 -0
  27. {python_injection-0.26.0 → python_injection-0.26.2}/injection/ext/fastapi.pyi +0 -0
  28. {python_injection-0.26.0 → python_injection-0.26.2}/injection/loaders.py +0 -0
  29. {python_injection-0.26.0 → python_injection-0.26.2}/injection/py.typed +0 -0
  30. {python_injection-0.26.0 → python_injection-0.26.2}/injection/testing/__init__.py +0 -0
  31. {python_injection-0.26.0 → python_injection-0.26.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.26.0
3
+ Version: 0.26.2
4
4
  Summary: Dead-simple dependency injection framework for Python.
5
5
  Project-URL: Documentation, https://python-injection.remimd.dev
6
6
  Project-URL: Repository, https://github.com/100nm/python-injection
@@ -23,7 +23,7 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
23
23
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
24
  Classifier: Topic :: Software Development :: Testing
25
25
  Classifier: Typing :: Typed
26
- Requires-Python: <3.15,>=3.12
26
+ Requires-Python: <3.16,>=3.12
27
27
  Requires-Dist: type-analyzer
28
28
  Provides-Extra: async
29
29
  Requires-Dist: anyio; extra == 'async'
@@ -212,6 +212,21 @@ def _bind_scope(
212
212
  stack.close()
213
213
 
214
214
 
215
+ class _SealedScopeCache(MutableMapping[Any, Any]):
216
+ __slots__ = ()
217
+
218
+ @staticmethod
219
+ def guard(*args: Any, **kwargs: Any) -> NoReturn:
220
+ raise ScopeError("Can't access cache of an exited scope.")
221
+
222
+ __delitem__ = __getitem__ = __iter__ = __len__ = __setitem__ = guard
223
+
224
+
225
+ _sealed_cache = _SealedScopeCache()
226
+
227
+ del _SealedScopeCache
228
+
229
+
215
230
  @runtime_checkable
216
231
  class Scope(Protocol):
217
232
  __slots__ = ()
@@ -227,14 +242,13 @@ class Scope(Protocol):
227
242
  raise NotImplementedError
228
243
 
229
244
 
230
- @dataclass(repr=False, frozen=True, slots=True)
245
+ @dataclass(repr=False, eq=False, slots=True)
231
246
  class BaseScope[T](Scope, ABC):
232
247
  delegate: T
233
- cache: MutableMapping[SlotKey[Any], Any] = field(
234
- default_factory=dict,
235
- init=False,
236
- hash=False,
237
- )
248
+ cache: MutableMapping[SlotKey[Any], Any] = field(default_factory=dict, init=False)
249
+
250
+ def close(self) -> None:
251
+ self.cache = _sealed_cache
238
252
 
239
253
 
240
254
  class AsyncScope(BaseScope[AsyncExitStack]):
@@ -253,6 +267,7 @@ class AsyncScope(BaseScope[AsyncExitStack]):
253
267
  exc_value: BaseException | None,
254
268
  traceback: TracebackType | None,
255
269
  ) -> Any:
270
+ self.close()
256
271
  return await self.delegate.__aexit__(exc_type, exc_value, traceback)
257
272
 
258
273
  async def aenter[T](self, context_manager: AsyncContextManager[T]) -> T:
@@ -278,6 +293,7 @@ class SyncScope(BaseScope[ExitStack]):
278
293
  exc_value: BaseException | None,
279
294
  traceback: TracebackType | None,
280
295
  ) -> Any:
296
+ self.close()
281
297
  return self.delegate.__exit__(exc_type, exc_value, traceback)
282
298
 
283
299
  async def aenter[T](self, context_manager: AsyncContextManager[T]) -> NoReturn:
@@ -24,12 +24,12 @@ test = [
24
24
 
25
25
  [project]
26
26
  name = "python-injection"
27
- version = "0.26.0"
27
+ version = "0.26.2"
28
28
  description = "Dead-simple dependency injection framework for Python."
29
29
  license = "MIT"
30
30
  license-files = ["LICENSE"]
31
31
  readme = "docs/index.md"
32
- requires-python = ">=3.12, <3.15"
32
+ requires-python = ">=3.12, <3.16"
33
33
  authors = [{ name = "remimd" }]
34
34
  keywords = ["dependencies", "dependency", "inject", "injection"]
35
35
  classifiers = [