(request: Request)
| 651 | items: list[int] |
| 652 | |
| 653 | async def hello_world(request: Request) -> Response: |
| 654 | class="cm"># modifications to the state should not leak across requests |
| 655 | assert request.state.count == 0 |
| 656 | class="cm"># modify the state, this should not leak to the lifespan or other requests |
| 657 | request.state.count += 1 |
| 658 | class="cm"># since state.items is a mutable object this modification _will_ leak across |
| 659 | class="cm"># requests and to the lifespan |
| 660 | request.state.items.append(1) |
| 661 | return PlainTextResponse(class="st">"hello, world") |
| 662 | |
| 663 | @contextlib.asynccontextmanager |
| 664 | async def lifespan(app: Starlette) -> AsyncIterator[State]: |
nothing calls this directly
no test coverage detected