|
1 | 1 | from collections.abc import AsyncIterator, Callable |
2 | 2 | from contextlib import AbstractAsyncContextManager, asynccontextmanager |
3 | 3 |
|
4 | | -from dishka import AsyncContainer, Provider, make_async_container |
| 4 | +from dishka import Provider, make_async_container |
5 | 5 | from dishka.integrations.fastapi import setup_dishka |
6 | 6 | from fastapi import FastAPI |
7 | 7 |
|
@@ -44,31 +44,6 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]: |
44 | 44 | return lifespan |
45 | 45 |
|
46 | 46 |
|
47 | | -def make_ioc_container( |
48 | | - *di_providers: Provider, |
49 | | - app_settings: AppSettings, |
50 | | - postgres_settings: PostgresSettings, |
51 | | - sqla_settings: SqlaSettings, |
52 | | - password_hasher_settings: PasswordHasherSettings, |
53 | | - jwt_settings: JwtSettings, |
54 | | - session_settings: SessionSettings, |
55 | | - cookie_settings: CookieSettings, |
56 | | -) -> AsyncContainer: |
57 | | - return make_async_container( |
58 | | - *get_providers(), |
59 | | - *di_providers, |
60 | | - context={ |
61 | | - AppSettings: app_settings, |
62 | | - PostgresSettings: postgres_settings, |
63 | | - SqlaSettings: sqla_settings, |
64 | | - PasswordHasherSettings: password_hasher_settings, |
65 | | - JwtSettings: jwt_settings, |
66 | | - SessionSettings: session_settings, |
67 | | - CookieSettings: cookie_settings, |
68 | | - }, |
69 | | - ) |
70 | | - |
71 | | - |
72 | 47 | def make_app( |
73 | 48 | *di_providers: Provider, |
74 | 49 | app_settings: AppSettings | None = None, |
@@ -106,15 +81,18 @@ def make_app( |
106 | 81 | lifespan=make_lifespan(), |
107 | 82 | root_path=app_settings.ROOT_PATH.rstrip("/"), |
108 | 83 | ) |
109 | | - container = make_ioc_container( |
| 84 | + container = make_async_container( |
| 85 | + *get_providers(), |
110 | 86 | *di_providers, |
111 | | - app_settings=app_settings, |
112 | | - postgres_settings=postgres_settings, |
113 | | - sqla_settings=sqla_settings, |
114 | | - password_hasher_settings=password_hasher_settings, |
115 | | - jwt_settings=jwt_settings, |
116 | | - session_settings=session_settings, |
117 | | - cookie_settings=cookie_settings, |
| 87 | + context={ |
| 88 | + AppSettings: app_settings, |
| 89 | + PostgresSettings: postgres_settings, |
| 90 | + SqlaSettings: sqla_settings, |
| 91 | + PasswordHasherSettings: password_hasher_settings, |
| 92 | + JwtSettings: jwt_settings, |
| 93 | + SessionSettings: session_settings, |
| 94 | + CookieSettings: cookie_settings, |
| 95 | + }, |
118 | 96 | ) |
119 | 97 | setup_dishka(container, app) |
120 | 98 | setup_middlewares(app, cookie_settings) |
|
0 commit comments