Coverage for docs_src / path_params_numeric_validations / tutorial006_an_py310.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.3, created at 2026-02-12 18:15 +0000

1from typing import Annotated 1def

2 

3from fastapi import FastAPI, Path, Query 1def

4 

5app = FastAPI() 1def

6 

7 

8@app.get("/items/{item_id}") 1def

9async def read_items( 1def

10 *, 

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

12 q: str, 

13 size: Annotated[float, Query(gt=0, lt=10.5)], 

14): 

15 results = {"item_id": item_id} 1abc

16 if q: 1abc

17 results.update({"q": q}) 1abc

18 if size: 1abc

19 results.update({"size": size}) 1abc

20 return results 1abc