Skip to content

Why not use the return type annotation for the response_model? #101

@JHSaunders

Description

@JHSaunders

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 item

You could concievably go:

@app.post("/items/") 
async def create_item(*, item: Item) -> Item:
    return item

which 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions