Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modern_di_fastapi/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import collections.abc
import contextlib
import dataclasses
import typing
Expand Down Expand Up @@ -42,7 +43,7 @@ def _compose_lifespan(original: Lifespan[fastapi.FastAPI]) -> Lifespan[fastapi.F
"""

@contextlib.asynccontextmanager
async def composed(app_: fastapi.FastAPI) -> typing.AsyncIterator[typing.Mapping[str, typing.Any] | None]:
async def composed(app_: fastapi.FastAPI) -> collections.abc.AsyncGenerator[typing.Mapping[str, typing.Any] | None]:
async with original(app_) as state, fetch_di_container(app_):
yield state

Expand Down
3 changes: 2 additions & 1 deletion tests/test_lifespan.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import collections.abc
import contextlib
import typing

Expand Down Expand Up @@ -32,7 +33,7 @@ def test_setup_di_composes_with_existing_lifespan() -> None:
events: list[str] = []

@contextlib.asynccontextmanager
async def user_lifespan(app_: fastapi.FastAPI) -> typing.AsyncIterator[dict[str, str]]:
async def user_lifespan(app_: fastapi.FastAPI) -> collections.abc.AsyncGenerator[dict[str, str]]:
assert isinstance(app_, fastapi.FastAPI)
events.append("startup")
yield {"marker": "from-user-lifespan"}
Expand Down
Loading