anydi 0.27.0a1__tar.gz → 0.27.0a2__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.0a1 → anydi-0.27.0a2}/PKG-INFO +3 -3
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/pytest_plugin.py +17 -24
- {anydi-0.27.0a1 → anydi-0.27.0a2}/pyproject.toml +3 -3
- {anydi-0.27.0a1 → anydi-0.27.0a2}/LICENSE +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/README.md +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/__init__.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/_container.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/_context.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/_logger.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/_module.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/_scanner.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/_types.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/_utils.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/__init__.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/_utils.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/django/__init__.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/django/_container.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/django/_settings.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/django/_utils.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/django/apps.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/django/middleware.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/django/ninja/__init__.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/django/ninja/_operation.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/django/ninja/_signature.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/fastapi.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/faststream.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/starlette/__init__.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/anydi/ext/starlette/middleware.py +0 -0
- {anydi-0.27.0a1 → anydi-0.27.0a2}/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.0a2
|
|
4
4
|
Summary: Dependency Injection library
|
|
5
5
|
Home-page: https://github.com/antonrh/anydi
|
|
6
6
|
License: MIT
|
|
@@ -33,8 +33,8 @@ Provides-Extra: async
|
|
|
33
33
|
Provides-Extra: docs
|
|
34
34
|
Requires-Dist: anyio (>=3.6.2,<4.0.0) ; extra == "async"
|
|
35
35
|
Requires-Dist: mkdocs (>=1.4.2,<2.0.0) ; extra == "docs"
|
|
36
|
-
Requires-Dist: mkdocs-material (>=9.
|
|
37
|
-
Requires-Dist: typing-extensions (>=4.
|
|
36
|
+
Requires-Dist: mkdocs-material (>=9.5.21,<10.0.0) ; extra == "docs"
|
|
37
|
+
Requires-Dist: typing-extensions (>=4.12.1,<5.0.0)
|
|
38
38
|
Project-URL: Repository, https://github.com/antonrh/anydi
|
|
39
39
|
Description-Content-Type: text/markdown
|
|
40
40
|
|
|
@@ -6,7 +6,6 @@ from typing import Any, Callable, Iterator, cast
|
|
|
6
6
|
import pytest
|
|
7
7
|
|
|
8
8
|
from anydi import Container
|
|
9
|
-
from anydi._types import is_marker
|
|
10
9
|
from anydi._utils import get_typed_parameters
|
|
11
10
|
|
|
12
11
|
|
|
@@ -24,12 +23,6 @@ def pytest_addoption(parser: pytest.Parser) -> None:
|
|
|
24
23
|
type="bool",
|
|
25
24
|
default=False,
|
|
26
25
|
)
|
|
27
|
-
parser.addini(
|
|
28
|
-
"anydi_inject_auto",
|
|
29
|
-
help="Automatically inject dependencies",
|
|
30
|
-
type="bool",
|
|
31
|
-
default=True,
|
|
32
|
-
)
|
|
33
26
|
|
|
34
27
|
|
|
35
28
|
CONTAINER_FIXTURE_NAME = "container"
|
|
@@ -71,17 +64,15 @@ def _anydi_injected_parameter_iterator(
|
|
|
71
64
|
_anydi_unresolved: list[str],
|
|
72
65
|
) -> Callable[[], Iterator[tuple[str, Any]]]:
|
|
73
66
|
registered_fixtures = request.session._fixturemanager._arg2fixturedefs # noqa
|
|
74
|
-
inject_auto = cast(bool, request.config.getini("anydi_inject_auto"))
|
|
75
67
|
|
|
76
68
|
def _iterator() -> Iterator[tuple[str, inspect.Parameter]]:
|
|
77
69
|
for parameter in get_typed_parameters(request.function):
|
|
78
70
|
interface = parameter.annotation
|
|
79
|
-
if
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if interface in _anydi_unresolved or parameter.name in registered_fixtures:
|
|
71
|
+
if (
|
|
72
|
+
interface is parameter.empty
|
|
73
|
+
or interface in _anydi_unresolved
|
|
74
|
+
or parameter.name in registered_fixtures
|
|
75
|
+
):
|
|
85
76
|
continue
|
|
86
77
|
yield parameter.name, interface
|
|
87
78
|
|
|
@@ -104,17 +95,18 @@ def _anydi_inject(
|
|
|
104
95
|
container = cast(Container, request.getfixturevalue("anydi_setup_container"))
|
|
105
96
|
|
|
106
97
|
for argname, interface in _anydi_injected_parameter_iterator():
|
|
98
|
+
# Skip if the interface is not registered
|
|
99
|
+
if container.strict and not container.is_registered(interface):
|
|
100
|
+
continue
|
|
101
|
+
|
|
107
102
|
# Release the instance if it was already resolved
|
|
108
103
|
if container.is_resolved(interface):
|
|
109
104
|
container.release(interface)
|
|
110
105
|
|
|
111
106
|
try:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
except LookupError:
|
|
107
|
+
request.node.funcargs[argname] = container.resolve(interface)
|
|
108
|
+
except Exception: # noqa
|
|
115
109
|
_anydi_unresolved.append(interface)
|
|
116
|
-
continue
|
|
117
|
-
request.node.funcargs[argname] = instance
|
|
118
110
|
|
|
119
111
|
|
|
120
112
|
@pytest.fixture(autouse=True)
|
|
@@ -132,14 +124,15 @@ async def _anydi_ainject(
|
|
|
132
124
|
container = cast(Container, request.getfixturevalue("anydi_setup_container"))
|
|
133
125
|
|
|
134
126
|
for argname, interface in _anydi_injected_parameter_iterator():
|
|
127
|
+
# Skip if the interface is not registered
|
|
128
|
+
if container.strict and not container.is_registered(interface):
|
|
129
|
+
continue
|
|
130
|
+
|
|
135
131
|
# Release the instance if it was already resolved
|
|
136
132
|
if container.is_resolved(interface):
|
|
137
133
|
container.release(interface)
|
|
138
134
|
|
|
139
135
|
try:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
except LookupError:
|
|
136
|
+
request.node.funcargs[argname] = await container.aresolve(interface)
|
|
137
|
+
except Exception: # noqa
|
|
143
138
|
_anydi_unresolved.append(interface)
|
|
144
|
-
continue
|
|
145
|
-
request.node.funcargs[argname] = instance
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "anydi"
|
|
3
|
-
version = "0.27.
|
|
3
|
+
version = "0.27.0a2"
|
|
4
4
|
description = "Dependency Injection library"
|
|
5
5
|
authors = ["Anton Ruhlov <antonruhlov@gmail.com>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -36,10 +36,10 @@ packages = [
|
|
|
36
36
|
|
|
37
37
|
[tool.poetry.dependencies]
|
|
38
38
|
python = "^3.8"
|
|
39
|
-
typing-extensions = "^4.
|
|
39
|
+
typing-extensions = "^4.12.1"
|
|
40
40
|
anyio = { version = "^3.6.2", optional = true }
|
|
41
41
|
mkdocs = { version = "^1.4.2", optional = true }
|
|
42
|
-
mkdocs-material = { version = "^9.
|
|
42
|
+
mkdocs-material = { version = "^9.5.21", optional = true }
|
|
43
43
|
|
|
44
44
|
[tool.poetry.extras]
|
|
45
45
|
docs = ["mkdocs", "mkdocs-material"]
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|