anydi 0.27.0a7__tar.gz → 0.27.1__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.
- {anydi-0.27.0a7 → anydi-0.27.1}/PKG-INFO +1 -2
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/_container.py +4 -4
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/_context.py +8 -9
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/_utils.py +12 -15
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/pytest_plugin.py +0 -8
- {anydi-0.27.0a7 → anydi-0.27.1}/pyproject.toml +4 -5
- {anydi-0.27.0a7 → anydi-0.27.1}/LICENSE +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/README.md +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/__init__.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/_logger.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/_module.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/_scanner.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/_types.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/__init__.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/_utils.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/django/__init__.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/django/_container.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/django/_settings.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/django/_utils.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/django/apps.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/django/middleware.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/django/ninja/__init__.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/django/ninja/_operation.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/django/ninja/_signature.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/fastapi.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/faststream.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/starlette/__init__.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/ext/starlette/middleware.py +0 -0
- {anydi-0.27.0a7 → anydi-0.27.1}/anydi/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: anydi
|
|
3
|
-
Version: 0.27.
|
|
3
|
+
Version: 0.27.1
|
|
4
4
|
Summary: Dependency Injection library
|
|
5
5
|
Home-page: https://github.com/antonrh/anydi
|
|
6
6
|
License: MIT
|
|
@@ -22,7 +22,6 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.11
|
|
23
23
|
Classifier: Programming Language :: Python :: 3.12
|
|
24
24
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
25
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
26
25
|
Classifier: Topic :: Internet
|
|
27
26
|
Classifier: Topic :: Software Development
|
|
28
27
|
Classifier: Topic :: Software Development :: Libraries
|
|
@@ -429,9 +429,9 @@ class Container:
|
|
|
429
429
|
exc_type: type[BaseException] | None,
|
|
430
430
|
exc_val: BaseException | None,
|
|
431
431
|
exc_tb: types.TracebackType | None,
|
|
432
|
-
) ->
|
|
432
|
+
) -> bool:
|
|
433
433
|
"""Exit the singleton context."""
|
|
434
|
-
self.
|
|
434
|
+
return self._singleton_context.__exit__(exc_type, exc_val, exc_tb)
|
|
435
435
|
|
|
436
436
|
def start(self) -> None:
|
|
437
437
|
"""Start the singleton context."""
|
|
@@ -464,9 +464,9 @@ class Container:
|
|
|
464
464
|
exc_type: type[BaseException] | None,
|
|
465
465
|
exc_val: BaseException | None,
|
|
466
466
|
exc_tb: types.TracebackType | None,
|
|
467
|
-
) ->
|
|
467
|
+
) -> bool:
|
|
468
468
|
"""Exit the singleton context."""
|
|
469
|
-
await self.
|
|
469
|
+
return await self._singleton_context.__aexit__(exc_type, exc_val, exc_tb)
|
|
470
470
|
|
|
471
471
|
async def astart(self) -> None:
|
|
472
472
|
"""Start the singleton context asynchronously."""
|
|
@@ -243,7 +243,7 @@ class ResourceScopedContext(ScopedContext):
|
|
|
243
243
|
exc_type: type[BaseException] | None,
|
|
244
244
|
exc_val: BaseException | None,
|
|
245
245
|
exc_tb: TracebackType | None,
|
|
246
|
-
) ->
|
|
246
|
+
) -> bool:
|
|
247
247
|
"""Exit the context.
|
|
248
248
|
|
|
249
249
|
Args:
|
|
@@ -251,8 +251,7 @@ class ResourceScopedContext(ScopedContext):
|
|
|
251
251
|
exc_val: The exception instance, if any.
|
|
252
252
|
exc_tb: The traceback, if any.
|
|
253
253
|
"""
|
|
254
|
-
self.
|
|
255
|
-
return
|
|
254
|
+
return self._stack.__exit__(exc_type, exc_val, exc_tb) # type: ignore[return-value]
|
|
256
255
|
|
|
257
256
|
@abc.abstractmethod
|
|
258
257
|
def start(self) -> None:
|
|
@@ -262,7 +261,7 @@ class ResourceScopedContext(ScopedContext):
|
|
|
262
261
|
|
|
263
262
|
def close(self) -> None:
|
|
264
263
|
"""Close the scoped context."""
|
|
265
|
-
self._stack.
|
|
264
|
+
self._stack.__exit__(None, None, None)
|
|
266
265
|
|
|
267
266
|
async def __aenter__(self) -> Self:
|
|
268
267
|
"""Enter the context asynchronously.
|
|
@@ -278,7 +277,7 @@ class ResourceScopedContext(ScopedContext):
|
|
|
278
277
|
exc_type: type[BaseException] | None,
|
|
279
278
|
exc_val: BaseException | None,
|
|
280
279
|
exc_tb: TracebackType | None,
|
|
281
|
-
) ->
|
|
280
|
+
) -> bool:
|
|
282
281
|
"""Exit the context asynchronously.
|
|
283
282
|
|
|
284
283
|
Args:
|
|
@@ -286,8 +285,9 @@ class ResourceScopedContext(ScopedContext):
|
|
|
286
285
|
exc_val: The exception instance, if any.
|
|
287
286
|
exc_tb: The traceback, if any.
|
|
288
287
|
"""
|
|
289
|
-
await
|
|
290
|
-
|
|
288
|
+
return await run_async(
|
|
289
|
+
self.__exit__, exc_type, exc_val, exc_tb
|
|
290
|
+
) or await self._async_stack.__aexit__(exc_type, exc_val, exc_tb)
|
|
291
291
|
|
|
292
292
|
@abc.abstractmethod
|
|
293
293
|
async def astart(self) -> None:
|
|
@@ -295,8 +295,7 @@ class ResourceScopedContext(ScopedContext):
|
|
|
295
295
|
|
|
296
296
|
async def aclose(self) -> None:
|
|
297
297
|
"""Close the scoped context asynchronously."""
|
|
298
|
-
await
|
|
299
|
-
await self._async_stack.aclose()
|
|
298
|
+
await self.__aexit__(None, None, None)
|
|
300
299
|
|
|
301
300
|
|
|
302
301
|
@final
|
|
@@ -6,7 +6,7 @@ import builtins
|
|
|
6
6
|
import functools
|
|
7
7
|
import inspect
|
|
8
8
|
import sys
|
|
9
|
-
from typing import Any, AsyncIterator, Callable, ForwardRef, Iterator, TypeVar
|
|
9
|
+
from typing import Any, AsyncIterator, Callable, ForwardRef, Iterator, TypeVar
|
|
10
10
|
|
|
11
11
|
from typing_extensions import ParamSpec, get_args, get_origin
|
|
12
12
|
|
|
@@ -16,17 +16,6 @@ except ImportError:
|
|
|
16
16
|
anyio = None # type: ignore[assignment]
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
if sys.version_info < (3, 9): # pragma: nocover
|
|
20
|
-
|
|
21
|
-
def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
|
|
22
|
-
return type_._evaluate(globalns, localns) # noqa
|
|
23
|
-
|
|
24
|
-
else:
|
|
25
|
-
|
|
26
|
-
def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
|
|
27
|
-
return cast(Any, type_)._evaluate(globalns, localns, set()) # noqa
|
|
28
|
-
|
|
29
|
-
|
|
30
19
|
T = TypeVar("T")
|
|
31
20
|
P = ParamSpec("P")
|
|
32
21
|
|
|
@@ -62,6 +51,12 @@ def is_builtin_type(tp: type[Any]) -> bool:
|
|
|
62
51
|
return tp.__module__ == builtins.__name__
|
|
63
52
|
|
|
64
53
|
|
|
54
|
+
def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
|
|
55
|
+
if sys.version_info < (3, 9):
|
|
56
|
+
return type_._evaluate(globalns, localns)
|
|
57
|
+
return type_._evaluate(globalns, localns, recursive_guard=frozenset())
|
|
58
|
+
|
|
59
|
+
|
|
65
60
|
def get_typed_annotation(
|
|
66
61
|
annotation: Any,
|
|
67
62
|
globalns: dict[str, Any],
|
|
@@ -70,10 +65,12 @@ def get_typed_annotation(
|
|
|
70
65
|
) -> Any:
|
|
71
66
|
"""Get the typed annotation of a parameter."""
|
|
72
67
|
if isinstance(annotation, str):
|
|
73
|
-
if sys.version_info
|
|
74
|
-
annotation = ForwardRef(annotation)
|
|
75
|
-
else:
|
|
68
|
+
if sys.version_info >= (3, 10, 2):
|
|
76
69
|
annotation = ForwardRef(annotation, module=module, is_class=is_class)
|
|
70
|
+
elif sys.version_info >= (3, 10, 0):
|
|
71
|
+
annotation = ForwardRef(annotation, module=module)
|
|
72
|
+
else:
|
|
73
|
+
annotation = ForwardRef(annotation)
|
|
77
74
|
annotation = evaluate_forwardref(annotation, globalns, {})
|
|
78
75
|
return annotation
|
|
79
76
|
|
|
@@ -99,10 +99,6 @@ def _anydi_inject(
|
|
|
99
99
|
if container.strict and not container.is_registered(interface):
|
|
100
100
|
continue
|
|
101
101
|
|
|
102
|
-
# Release the instance if it was already resolved
|
|
103
|
-
if container.is_resolved(interface):
|
|
104
|
-
container.release(interface)
|
|
105
|
-
|
|
106
102
|
try:
|
|
107
103
|
request.node.funcargs[argname] = container.resolve(interface)
|
|
108
104
|
except Exception: # noqa
|
|
@@ -128,10 +124,6 @@ async def _anydi_ainject(
|
|
|
128
124
|
if container.strict and not container.is_registered(interface):
|
|
129
125
|
continue
|
|
130
126
|
|
|
131
|
-
# Release the instance if it was already resolved
|
|
132
|
-
if container.is_resolved(interface):
|
|
133
|
-
container.release(interface)
|
|
134
|
-
|
|
135
127
|
try:
|
|
136
128
|
request.node.funcargs[argname] = await container.aresolve(interface)
|
|
137
129
|
except Exception: # noqa
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "anydi"
|
|
3
|
-
version = "0.27.
|
|
3
|
+
version = "0.27.1"
|
|
4
4
|
description = "Dependency Injection library"
|
|
5
5
|
authors = ["Anton Ruhlov <antonruhlov@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -22,7 +22,6 @@ classifiers = [
|
|
|
22
22
|
"Intended Audience :: Developers",
|
|
23
23
|
"License :: OSI Approved :: MIT License",
|
|
24
24
|
"Programming Language :: Python :: 3",
|
|
25
|
-
"Programming Language :: Python :: 3.7",
|
|
26
25
|
"Programming Language :: Python :: 3.8",
|
|
27
26
|
"Programming Language :: Python :: 3.9",
|
|
28
27
|
"Programming Language :: Python :: 3.10",
|
|
@@ -46,9 +45,9 @@ docs = ["mkdocs", "mkdocs-material"]
|
|
|
46
45
|
async = ["anyio"]
|
|
47
46
|
|
|
48
47
|
[tool.poetry.group.dev.dependencies]
|
|
49
|
-
mypy = "^1.
|
|
50
|
-
ruff = "^0.4
|
|
51
|
-
pytest = "^8.1
|
|
48
|
+
mypy = "^1.11.0"
|
|
49
|
+
ruff = "^0.5.4"
|
|
50
|
+
pytest = "^8.3.1"
|
|
52
51
|
pytest-cov = "^5.0.0"
|
|
53
52
|
fastapi = "^0.100.0"
|
|
54
53
|
httpx = "^0.26.0"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|