You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've implemented a basic version of the quickstart example using pydantic models:
frompydanticimportBaseModelfromdatetimeimportdatetimefromquartimportQuartfromquart_schemaimportQuartSchema, validate_request, validate_responseapp=Quart(__name__)
QuartSchema(app)
classTodo(BaseModel):
task: strdue: datetime|None@app.route("/", methods=["POST"])@validate_request(Todo)@validate_response(Todo, 201)asyncdefcreate_todo(data: Todo) ->tuple[Todo, int]:
"""Create a Todo"""# Do something with data, e.g. save to the DBprint(data)
returndata, 201
This 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.
The text was updated successfully, but these errors were encountered:
I've implemented a basic version of the quickstart example using pydantic models:
This 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.
The text was updated successfully, but these errors were encountered: