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

11 statements  

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

1from datetime import datetime, time, timedelta 1abcde

2from typing import Union 1abcde

3from uuid import UUID 1abcde

4 

5from fastapi import Body, FastAPI 1abcde

6from typing_extensions import Annotated 1abcde

7 

8app = FastAPI() 1abcde

9 

10 

11@app.put("/items/{item_id}") 1abcde

12async def read_items( 1abcde

13 item_id: UUID, 

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

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

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

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

18): 

19 start_process = start_datetime + process_after 1abcde

20 duration = end_datetime - start_process 1abcde

21 return { 1abcde

22 "item_id": item_id, 

23 "start_datetime": start_datetime, 

24 "end_datetime": end_datetime, 

25 "process_after": process_after, 

26 "repeat_at": repeat_at, 

27 "start_process": start_process, 

28 "duration": duration, 

29 }