-
-
Notifications
You must be signed in to change notification settings - Fork 9k
Why not use the return type annotation for the response_model? #101
Copy link
Copy link
Closed
Labels
Description
Description
This is a very minor question on chosen syntax. Why not use the return type annotation for the response_model? For example rather than:
@app.post("/items/", response_model=Item)
async def create_item(*, item: Item):
return itemYou could concievably go:
@app.post("/items/")
async def create_item(*, item: Item) -> Item:
return itemwhich just seems like it uses the language facilities better and is a bit more pythonic. There is no real change in feature set, and I am sure i was thought of, but what was the reasoning behind not doing it?
Reactions are currently unavailable