Coverage for docs_src/extra_data_types/tutorial001_an_py39.py: 100%

10 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1from datetime import datetime, time, timedelta 1abcd

2from typing import Annotated, Union 1abcd

3from uuid import UUID 1abcd

4 

5from fastapi import Body, FastAPI 1abcd

6 

7app = FastAPI() 1abcd

8 

9 

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

11async def read_items( 1abcd

12 item_id: UUID, 

13 start_datetime: Annotated[datetime, Body()], 

14 end_datetime: Annotated[datetime, Body()], 

15 process_after: Annotated[timedelta, Body()], 

16 repeat_at: Annotated[Union[time, None], Body()] = None, 

17): 

18 start_process = start_datetime + process_after 1abcd

19 duration = end_datetime - start_process 1abcd

20 return { 1abcd

21 "item_id": item_id, 

22 "start_datetime": start_datetime, 

23 "end_datetime": end_datetime, 

24 "process_after": process_after, 

25 "repeat_at": repeat_at, 

26 "start_process": start_process, 

27 "duration": duration, 

28 }