Browse Source

🎨 Update type annotations for `response_model`, allow things like `Union[str, None]` (#5294)

pull/5301/head
Sebastián Ramírez 3 years ago
committed by GitHub
parent
commit
e7b1b96a54
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      fastapi/applications.py
  2. 22
      fastapi/routing.py

20
fastapi/applications.py

@ -273,7 +273,7 @@ class FastAPI(Starlette):
path: str,
endpoint: Callable[..., Coroutine[Any, Any, Response]],
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,
@ -331,7 +331,7 @@ class FastAPI(Starlette):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,
@ -434,7 +434,7 @@ class FastAPI(Starlette):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,
@ -489,7 +489,7 @@ class FastAPI(Starlette):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,
@ -544,7 +544,7 @@ class FastAPI(Starlette):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,
@ -599,7 +599,7 @@ class FastAPI(Starlette):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,
@ -654,7 +654,7 @@ class FastAPI(Starlette):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,
@ -709,7 +709,7 @@ class FastAPI(Starlette):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,
@ -764,7 +764,7 @@ class FastAPI(Starlette):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,
@ -819,7 +819,7 @@ class FastAPI(Starlette):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[Depends]] = None,

22
fastapi/routing.py

@ -315,7 +315,7 @@ class APIRoute(routing.Route):
path: str,
endpoint: Callable[..., Any],
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -511,7 +511,7 @@ class APIRouter(routing.Router):
path: str,
endpoint: Callable[..., Any],
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -592,7 +592,7 @@ class APIRouter(routing.Router):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -787,7 +787,7 @@ class APIRouter(routing.Router):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -843,7 +843,7 @@ class APIRouter(routing.Router):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -899,7 +899,7 @@ class APIRouter(routing.Router):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -955,7 +955,7 @@ class APIRouter(routing.Router):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -1011,7 +1011,7 @@ class APIRouter(routing.Router):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -1067,7 +1067,7 @@ class APIRouter(routing.Router):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -1123,7 +1123,7 @@ class APIRouter(routing.Router):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,
@ -1179,7 +1179,7 @@ class APIRouter(routing.Router):
self,
path: str,
*,
response_model: Optional[Type[Any]] = None,
response_model: Any = None,
status_code: Optional[int] = None,
tags: Optional[List[Union[str, Enum]]] = None,
dependencies: Optional[Sequence[params.Depends]] = None,

Loading…
Cancel
Save