|
2 | 2 |
|
3 | 3 | import logging |
4 | 4 | from collections.abc import Awaitable, Callable |
| 5 | +from contextlib import AbstractAsyncContextManager |
5 | 6 | from http import HTTPStatus |
6 | | -from typing import Any, cast, AsyncContextManager |
| 7 | +from typing import Any, cast |
7 | 8 |
|
8 | 9 | from fastapi import FastAPI, Request, Response |
9 | 10 | from fastapi.exceptions import RequestValidationError |
@@ -225,18 +226,18 @@ class AppUtils: |
225 | 226 |
|
226 | 227 | @classmethod |
227 | 228 | def create_fastapi_app( |
228 | | - cls, |
229 | | - config: BaseConfig | None = None, |
230 | | - *, |
231 | | - configure_exception_handlers: bool = True, |
232 | | - lifespan: Callable[..., AsyncContextManager] | None = None, |
| 229 | + cls, |
| 230 | + config: BaseConfig | None = None, |
| 231 | + *, |
| 232 | + configure_exception_handlers: bool = True, |
| 233 | + lifespan: Callable[..., AbstractAsyncContextManager] | None = None, |
233 | 234 | ) -> FastAPI: |
234 | 235 | """Creates and configures a FastAPI application. |
235 | 236 |
|
236 | 237 | Args: |
237 | 238 | config (BaseConfig | None): Optional custom configuration. If not provided, uses global config. |
238 | 239 | configure_exception_handlers (bool): Whether to configure exception handlers. |
239 | | - lifespan (Callable[..., AsyncContextManager] | None): Optional lifespan context manager for the app. |
| 240 | + lifespan: Callable[..., AbstractAsyncContextManager] | None = None, |
240 | 241 |
|
241 | 242 | Returns: |
242 | 243 | FastAPI: The configured FastAPI application instance. |
|
0 commit comments