python-injection 0.25.14__tar.gz → 0.25.15__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.25.14 → python_injection-0.25.15}/PKG-INFO +1 -1
  2. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/injectables.py +5 -26
  3. {python_injection-0.25.14 → python_injection-0.25.15}/pyproject.toml +1 -1
  4. {python_injection-0.25.14 → python_injection-0.25.15}/.gitignore +0 -0
  5. {python_injection-0.25.14 → python_injection-0.25.15}/LICENSE +0 -0
  6. {python_injection-0.25.14 → python_injection-0.25.15}/docs/index.md +0 -0
  7. {python_injection-0.25.14 → python_injection-0.25.15}/injection/__init__.py +0 -0
  8. {python_injection-0.25.14 → python_injection-0.25.15}/injection/__init__.pyi +0 -0
  9. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/__init__.py +0 -0
  10. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/asfunction.py +0 -0
  11. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/__init__.py +0 -0
  12. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/asynchronous.py +0 -0
  13. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/event.py +0 -0
  14. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/invertible.py +0 -0
  15. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/lazy.py +0 -0
  16. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/threading.py +0 -0
  17. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/type.py +0 -0
  18. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/descriptors.py +0 -0
  19. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/locator.py +0 -0
  20. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/module.py +0 -0
  21. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/scope.py +0 -0
  22. {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/slots.py +0 -0
  23. {python_injection-0.25.14 → python_injection-0.25.15}/injection/entrypoint.py +0 -0
  24. {python_injection-0.25.14 → python_injection-0.25.15}/injection/exceptions.py +0 -0
  25. {python_injection-0.25.14 → python_injection-0.25.15}/injection/ext/__init__.py +0 -0
  26. {python_injection-0.25.14 → python_injection-0.25.15}/injection/ext/fastapi.py +0 -0
  27. {python_injection-0.25.14 → python_injection-0.25.15}/injection/ext/fastapi.pyi +0 -0
  28. {python_injection-0.25.14 → python_injection-0.25.15}/injection/loaders.py +0 -0
  29. {python_injection-0.25.14 → python_injection-0.25.15}/injection/py.typed +0 -0
  30. {python_injection-0.25.14 → python_injection-0.25.15}/injection/testing/__init__.py +0 -0
  31. {python_injection-0.25.14 → python_injection-0.25.15}/injection/testing/__init__.pyi +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-injection
3
- Version: 0.25.14
3
+ Version: 0.25.15
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
@@ -1,6 +1,6 @@
1
1
  from abc import ABC, abstractmethod
2
- from collections.abc import Awaitable, Callable, Iterator, MutableMapping
3
- from contextlib import contextmanager, suppress
2
+ from collections.abc import Awaitable, Callable, MutableMapping
3
+ from contextlib import suppress
4
4
  from dataclasses import dataclass, field
5
5
  from functools import partial
6
6
  from typing import (
@@ -53,13 +53,11 @@ class TransientInjectable[T](Injectable[T]):
53
53
 
54
54
 
55
55
  class CacheLogic[T]:
56
- __slots__ = ("__is_instantiating", "__semaphore")
56
+ __slots__ = ("__semaphore",)
57
57
 
58
- __is_instantiating: bool
59
58
  __semaphore: AsyncContextManager[Any]
60
59
 
61
60
  def __init__(self) -> None:
62
- self.__is_instantiating = False
63
61
  self.__semaphore = AsyncSemaphore(1)
64
62
 
65
63
  async def aget_or_create[K](
@@ -68,14 +66,11 @@ class CacheLogic[T]:
68
66
  key: K,
69
67
  factory: Callable[..., Awaitable[T]],
70
68
  ) -> T:
71
- self.__fail_if_instantiating()
72
69
  async with self.__semaphore:
73
70
  with suppress(KeyError):
74
71
  return cache[key]
75
72
 
76
- with self.__instantiating():
77
- instance = await factory()
78
-
73
+ instance = await factory()
79
74
  cache[key] = instance
80
75
 
81
76
  return instance
@@ -86,29 +81,13 @@ class CacheLogic[T]:
86
81
  key: K,
87
82
  factory: Callable[..., T],
88
83
  ) -> T:
89
- self.__fail_if_instantiating()
90
84
  with suppress(KeyError):
91
85
  return cache[key]
92
86
 
93
- with self.__instantiating():
94
- instance = factory()
95
-
87
+ instance = factory()
96
88
  cache[key] = instance
97
89
  return instance
98
90
 
99
- def __fail_if_instantiating(self) -> None:
100
- if self.__is_instantiating:
101
- raise RecursionError("Recursive call detected during instantiation.")
102
-
103
- @contextmanager
104
- def __instantiating(self) -> Iterator[None]:
105
- self.__is_instantiating = True
106
-
107
- try:
108
- yield
109
- finally:
110
- self.__is_instantiating = False
111
-
112
91
 
113
92
  @dataclass(repr=False, eq=False, frozen=True, slots=True)
114
93
  class SingletonInjectable[T](Injectable[T]):
@@ -24,7 +24,7 @@ test = [
24
24
 
25
25
  [project]
26
26
  name = "python-injection"
27
- version = "0.25.14"
27
+ version = "0.25.15"
28
28
  description = "Dead-simple dependency injection framework for Python."
29
29
  license = "MIT"
30
30
  license-files = ["LICENSE"]