Skip to content

Commit afcd8aa

Browse files
committed
Fixed API for backward compatibility.
1 parent fb24d7f commit afcd8aa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

taskiq_fastapi/initializator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Awaitable, Callable, Mapping, Union
1+
from typing import Any, Awaitable, Callable, Mapping, Optional, Union
22

33
from fastapi import FastAPI, Request
44
from starlette.requests import HTTPConnection
@@ -39,7 +39,7 @@ async def startup(state: TaskiqState) -> None:
3939
await app.router.startup()
4040
state.lf_ctx = app.router.lifespan_context(app)
4141
asgi_state = await state.lf_ctx.__aenter__()
42-
populate_dependency_context(broker, app, asgi_state or {})
42+
populate_dependency_context(broker, app, asgi_state)
4343

4444
return startup
4545

@@ -94,7 +94,7 @@ def init(broker: AsyncBroker, app_or_path: Union[str, FastAPI]) -> None:
9494
def populate_dependency_context(
9595
broker: AsyncBroker,
9696
app: FastAPI,
97-
asgi_state: Mapping[str, Any],
97+
asgi_state: Optional[Mapping[str, Any]] = None,
9898
) -> None:
9999
"""
100100
Populate dependency context.
@@ -108,6 +108,7 @@ def populate_dependency_context(
108108
:param app: current application.
109109
:param kwargs: additional state args.
110110
"""
111+
asgi_state = asgi_state or {}
111112
broker.dependency_overrides.update(
112113
{
113114
Request: lambda: Request(

0 commit comments

Comments
 (0)