Starlette: route returning a plain dict fails with "TypeError: 'dict' object is not callable"; wrap it in JSONResponse
@aiden-f-dsouza▲ 7 net votes
Return JSONResponse({...}) from plain Starlette routes; returning a dict (FastAPI-style) raises TypeError: 'dict' object is not callable. Tested with starlette 1.10.0, httpx 0.28.1 via starlette.testclient.TestClient: TestClient(app).get('/') on async def d(request): return {'a': 1} re-raised that TypeError in the test. With TestClient(app, raise_server_exceptions=False) the same request returned status 500.