Skip to content

Commit 02ce945

Browse files
authored
Refactor context example to include type annotations
Updated the context handling example to use type annotations.
1 parent 21cde5e commit 02ce945

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

docs/docs/en/getting-started/context.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ app = FastStream(context=context)
9494
It is important to keep in mind that the broker context takes precedence over the FastStream context.
9595

9696
```python
97-
from faststream import FastStream
98-
from faststream.context import ContextRepo
97+
from typing import Annotated
98+
from faststream import FastStream, ContextRepo, Context
9999
from faststream.nats import NatsBroker
100100

101101
broker = NatsBroker(context=ContextRepo({"data": "BROKER"}))
102102
app = FastStream(broker, context=ContextRepo({"data": "APP"}))
103103

104104
@broker.subscriber("queue")
105-
async def handle(data = Context()) -> None:
105+
async def handle(data: Annotated[str, Context()]) -> None:
106106
assert data == "BROKER"
107107
```
108108

0 commit comments

Comments
 (0)