Coverage for docs_src/body_multiple_params/tutorial001_py310.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2025-05-05 00:03 +0000

1from fastapi import FastAPI, Path 1abcd

2from pydantic import BaseModel 1abcd

3 

4app = FastAPI() 1abcd

5 

6 

7class Item(BaseModel): 1abcd

8 name: str 1abcd

9 description: str | None = None 1abcd

10 price: float 1abcd

11 tax: float | None = None 1abcd

12 

13 

14@app.put("/items/{item_id}") 1abcd

15async def update_item( 1abcd

16 *, 

17 item_id: int = Path(title="The ID of the item to get", ge=0, le=1000), 

18 q: str | None = None, 

19 item: Item | None = None, 

20): 

21 results = {"item_id": item_id} 1emifnjgokhpl

22 if q: 1emifnjgokhpl

23 results.update({"q": q}) 1eifjgkhl

24 if item: 1emifnjgokhpl

25 results.update({"item": item}) 1efgh

26 return results 1emifnjgokhpl