-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
I've implemented a basic version of the quickstart example using pydantic models:
from pydantic import BaseModel
from datetime import datetime
from quart import Quart
from quart_schema import QuartSchema, validate_request, validate_response
app = Quart(__name__)
QuartSchema(app)
class Todo(BaseModel):
task: str
due: datetime | None
@app.route("/", methods=["POST"])
@validate_request(Todo)
@validate_response(Todo, 201)
async def create_todo(data: Todo) -> tuple[Todo, int]:
"""Create a Todo"""
# Do something with data, e.g. save to the DB
print(data)
return data, 201This works (the docs get generated), but pylance reports a type error (Argument of type "(data: Todo) -> Coroutine[Any, Any, tuple[Todo, int]]" cannot be assigned to parameter of type "T_route@route" -- see screenshot from VS Code). As far as I understand, it's because Pydantic are not one of the Quart return types, but I guess I would have expected the @validate_response decorator to have done some kind of type coercion?
I'm not totally sure how Quart-Schema works so sorry if this issue actually belongs elsewhere. Thanks.
Metadata
Metadata
Assignees
Labels
No labels
