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.
- {python_injection-0.25.14 → python_injection-0.25.15}/PKG-INFO +1 -1
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/injectables.py +5 -26
- {python_injection-0.25.14 → python_injection-0.25.15}/pyproject.toml +1 -1
- {python_injection-0.25.14 → python_injection-0.25.15}/.gitignore +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/LICENSE +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/docs/index.md +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/__init__.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/__init__.pyi +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/__init__.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/asfunction.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/__init__.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/asynchronous.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/event.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/invertible.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/lazy.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/threading.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/type.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/descriptors.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/locator.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/module.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/scope.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/slots.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/entrypoint.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/exceptions.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/ext/__init__.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/ext/fastapi.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/ext/fastapi.pyi +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/loaders.py +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/py.typed +0 -0
- {python_injection-0.25.14 → python_injection-0.25.15}/injection/testing/__init__.py +0 -0
- {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.
|
|
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,
|
|
3
|
-
from contextlib import
|
|
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__ = ("
|
|
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
|
-
|
|
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
|
-
|
|
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]):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_injection-0.25.14 → python_injection-0.25.15}/injection/_core/common/asynchronous.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|