FastAPI router type error: "Untyped decorator males function untyped"

Viewed 12

I'm building an API with FastAPI. I want the API to be type-safe, but running mypy on a route returns this error: "Untyped decorator males function 'get_overview' untyped". Here's my route:

router = APIRouter()

@router.post("/overview/{location_id}")
async def get_overview(location_id: str) -> object:
    if 4 not in fake_items_db:
        raise HTTPException(status_code=404, detail="Item not found")
    return overview

This post provides a solution to the error, but doesn't work with the router API.

Is there a FastAPI-specific solution to this error?

0 Answers
Related