anydi 0.56.0__py3-none-any.whl → 0.57.0__py3-none-any.whl
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/__init__.py +4 -2
- anydi/_container.py +57 -104
- anydi/_injector.py +132 -0
- anydi/_scanner.py +52 -44
- anydi/_types.py +48 -7
- anydi/ext/fastapi.py +31 -33
- anydi/ext/faststream.py +25 -31
- anydi/ext/pydantic_settings.py +2 -1
- anydi/ext/pytest_plugin.py +380 -50
- {anydi-0.56.0.dist-info → anydi-0.57.0.dist-info}/METADATA +9 -10
- {anydi-0.56.0.dist-info → anydi-0.57.0.dist-info}/RECORD +13 -12
- {anydi-0.56.0.dist-info → anydi-0.57.0.dist-info}/WHEEL +0 -0
- {anydi-0.56.0.dist-info → anydi-0.57.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: anydi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.57.0
|
|
4
4
|
Summary: Dependency Injection library
|
|
5
5
|
Keywords: dependency injection,dependencies,di,async,asyncio,application
|
|
6
6
|
Author: Anton Ruhlov
|
|
@@ -116,19 +116,18 @@ if __name__ == "__main__":
|
|
|
116
116
|
### Inject Into Functions (`app/main.py`)
|
|
117
117
|
|
|
118
118
|
```python
|
|
119
|
-
from anydi import
|
|
119
|
+
from anydi import Provide
|
|
120
120
|
|
|
121
121
|
from app.container import container
|
|
122
122
|
from app.services import GreetingService
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
def greet(service: GreetingService = Inject()) -> str:
|
|
125
|
+
def greet(service: Provide[GreetingService]) -> str:
|
|
127
126
|
return service.greet("World")
|
|
128
127
|
|
|
129
128
|
|
|
130
129
|
if __name__ == "__main__":
|
|
131
|
-
print(greet
|
|
130
|
+
print(container.run(greet))
|
|
132
131
|
```
|
|
133
132
|
|
|
134
133
|
### Test with Overrides (`tests/test_app.py`)
|
|
@@ -146,7 +145,7 @@ def test_greet() -> None:
|
|
|
146
145
|
service_mock.greet.return_value = "Mocked"
|
|
147
146
|
|
|
148
147
|
with container.override(GreetingService, service_mock):
|
|
149
|
-
result = greet
|
|
148
|
+
result = container.run(greet)
|
|
150
149
|
|
|
151
150
|
assert result == "Mocked"
|
|
152
151
|
```
|
|
@@ -158,8 +157,8 @@ from typing import Annotated
|
|
|
158
157
|
|
|
159
158
|
import anydi.ext.fastapi
|
|
160
159
|
from fastapi import FastAPI
|
|
161
|
-
from anydi.ext.fastapi import Inject
|
|
162
160
|
|
|
161
|
+
from anydi import Provide
|
|
163
162
|
from app.container import container
|
|
164
163
|
from app.services import GreetingService
|
|
165
164
|
|
|
@@ -169,7 +168,7 @@ app = FastAPI()
|
|
|
169
168
|
|
|
170
169
|
@app.get("/greeting")
|
|
171
170
|
async def greet(
|
|
172
|
-
service:
|
|
171
|
+
service: Provide[GreetingService]
|
|
173
172
|
) -> dict[str, str]:
|
|
174
173
|
return {"greeting": service.greet("World")}
|
|
175
174
|
|
|
@@ -245,7 +244,7 @@ Wire Django Ninja (`urls.py`):
|
|
|
245
244
|
```python
|
|
246
245
|
from typing import Annotated, Any
|
|
247
246
|
|
|
248
|
-
from anydi import
|
|
247
|
+
from anydi import Provide
|
|
249
248
|
from django.http import HttpRequest
|
|
250
249
|
from django.urls import path
|
|
251
250
|
from ninja import NinjaAPI
|
|
@@ -257,7 +256,7 @@ api = NinjaAPI()
|
|
|
257
256
|
|
|
258
257
|
|
|
259
258
|
@api.get("/greeting")
|
|
260
|
-
def greet(request: HttpRequest, service:
|
|
259
|
+
def greet(request: HttpRequest, service: Provide[GreetingService]) -> Any:
|
|
261
260
|
return {"greeting": service.greet("World")}
|
|
262
261
|
|
|
263
262
|
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
anydi/__init__.py,sha256=
|
|
1
|
+
anydi/__init__.py,sha256=bQKzn9qfNnIMi1m3J-DdSknSDwNg8j08fdQg_-Edkto,613
|
|
2
2
|
anydi/_async_lock.py,sha256=3dwZr0KthXFYha0XKMyXf8jMmGb1lYoNC0O5w29V9ic,1104
|
|
3
|
-
anydi/_container.py,sha256=
|
|
3
|
+
anydi/_container.py,sha256=Zdy0KtOVRlyBSblAk2MEFp13RwJkfljpB2szR5VTHQQ,22975
|
|
4
4
|
anydi/_context.py,sha256=-9QqeMWo9OpZVXZxZCQgIsswggl3Ch7lgx1KiFX_ezc,3752
|
|
5
5
|
anydi/_decorators.py,sha256=J3W261ZAG7q4XKm4tbAv1wsWr9ysx9_5MUbUvSJB_MQ,2809
|
|
6
|
+
anydi/_injector.py,sha256=IxKTh2rzMHrsW554tbiJl33Hb5sRGKYY_NU1rC4UvxE,4378
|
|
6
7
|
anydi/_module.py,sha256=2kN5uEXLd2Dsc58gz5IWK43wJewr_QgIVGSO3iWp798,2609
|
|
7
8
|
anydi/_provider.py,sha256=OV1WFHTYv7W2U0XDk_Kql1r551Vhq8o-pUV5ep1HQcU,1574
|
|
8
9
|
anydi/_resolver.py,sha256=-MF2KsERF5qzU6uqYPF1fI58isgsjxXPLERylzFFDHE,28787
|
|
9
|
-
anydi/_scanner.py,sha256=
|
|
10
|
-
anydi/_types.py,sha256=
|
|
10
|
+
anydi/_scanner.py,sha256=rbRkHzyd2zMu7AFLffN6_tZJcMaW9gy7E-lVdHLHYrs,4294
|
|
11
|
+
anydi/_types.py,sha256=gpanGqXjF9WQFFn62kyIod6m1dE97vV-L2u2Y2nWie8,2933
|
|
11
12
|
anydi/ext/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
13
|
anydi/ext/django/__init__.py,sha256=Ve8lncLU9dPY_Vjt4zihPgsSxwAtFHACn0XvBM5JG8k,367
|
|
13
|
-
anydi/ext/fastapi.py,sha256=
|
|
14
|
-
anydi/ext/faststream.py,sha256=
|
|
15
|
-
anydi/ext/pydantic_settings.py,sha256=
|
|
16
|
-
anydi/ext/pytest_plugin.py,sha256=
|
|
14
|
+
anydi/ext/fastapi.py,sha256=8kXdO6RPwRbPyUh6YirdEPE-clJKXE--n-TAYI2hZf8,2326
|
|
15
|
+
anydi/ext/faststream.py,sha256=XT80r1FGL-xlU7r8urm9sNpUfl4OPMJseW4dade_fR4,1836
|
|
16
|
+
anydi/ext/pydantic_settings.py,sha256=jVJZ1wPaPpsxdNPlJj9yq282ebqLZ9tckWpZ0eIwWLg,1533
|
|
17
|
+
anydi/ext/pytest_plugin.py,sha256=M54DkA-KxD9GqLnXdoCyn-Qur2c44MB6d0AgJuYCZ5w,16171
|
|
17
18
|
anydi/ext/starlette/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
19
|
anydi/ext/starlette/middleware.py,sha256=MxnzshAs-CMvjJp0r457k52MzBL8O4KAuClnF6exBdU,803
|
|
19
20
|
anydi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
21
|
anydi/testing.py,sha256=cHg3mMScZbEep9smRqSNQ81BZMQOkyugHe8TvKdPnEg,1347
|
|
21
|
-
anydi-0.
|
|
22
|
-
anydi-0.
|
|
23
|
-
anydi-0.
|
|
24
|
-
anydi-0.
|
|
22
|
+
anydi-0.57.0.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
23
|
+
anydi-0.57.0.dist-info/entry_points.txt,sha256=AgOcQYM5KyS4D37QcYb00tiid0QA-pD1VrjHHq4QAps,44
|
|
24
|
+
anydi-0.57.0.dist-info/METADATA,sha256=w3aIoTTCQHgCRT1X-JnQ_VrEUz1hUl--PcktWO8fw2M,6534
|
|
25
|
+
anydi-0.57.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|