Is there an existing issue for this?
Describe the bug
Hello,
When I use the route handlers not as a decorator I get mypy errors being sad that I'm not awaiting my async function
class MyClassThatHasRoutes:
def setup_routes(self, app: sanic.Sanic[sanic.Config, SimpleNamespace]) -> None:
app.get("/api")(self.api) # error: Value of type "Coroutine[Any, Any, HTTPResponse | None]" must be used [unused-coroutine]
async def api(self, request: sanic.Request) -> sanic.response.HTTPResponse:
return sanic.empty(200)
I get that it's designed to be used as a decorator, but it makes sense where I'm doing this that I'm not.
I believe this could be fixed if RouteHandler was changed to have a return annotation of Awaitable[HTTPResponse | None] rather than Coroutine.
Is that something that could be done or do you see problems with doing that?
Code snippet
No response
Expected Behavior
No response
How do you run Sanic?
ASGI
Operating System
Linux
Sanic Version
25.12.0
Additional context
No response
Is there an existing issue for this?
Describe the bug
Hello,
When I use the route handlers not as a decorator I get mypy errors being sad that I'm not awaiting my async function
I get that it's designed to be used as a decorator, but it makes sense where I'm doing this that I'm not.
I believe this could be fixed if RouteHandler was changed to have a return annotation of
Awaitable[HTTPResponse | None]rather than Coroutine.Is that something that could be done or do you see problems with doing that?
Code snippet
No response
Expected Behavior
No response
How do you run Sanic?
ASGI
Operating System
Linux
Sanic Version
25.12.0
Additional context
No response