Browse Source

Fix types

pull/11050/head
Alexey Kotenko 1 year ago
parent
commit
304b55d658
  1. 8
      fastapi/applications.py
  2. 10
      fastapi/routing.py
  3. 3
      tests/test_operations_signatures.py

8
fastapi/applications.py

@ -2186,6 +2186,7 @@ class FastAPI(Starlette):
"""
return self.router.put(
path,
*args,
response_model=response_model,
status_code=status_code,
tags=tags,
@ -2208,7 +2209,6 @@ class FastAPI(Starlette):
callbacks=callbacks,
openapi_extra=openapi_extra,
generate_unique_id_function=generate_unique_id_function,
*args,
**kwargs
)
@ -2567,6 +2567,7 @@ class FastAPI(Starlette):
"""
return self.router.post(
path,
*args,
response_model=response_model,
status_code=status_code,
tags=tags,
@ -2589,7 +2590,6 @@ class FastAPI(Starlette):
callbacks=callbacks,
openapi_extra=openapi_extra,
generate_unique_id_function=generate_unique_id_function,
*args,
**kwargs,
)
@ -2943,6 +2943,7 @@ class FastAPI(Starlette):
"""
return self.router.delete(
path,
*args,
response_model=response_model,
status_code=status_code,
tags=tags,
@ -2965,7 +2966,6 @@ class FastAPI(Starlette):
callbacks=callbacks,
openapi_extra=openapi_extra,
generate_unique_id_function=generate_unique_id_function,
*args,
**kwargs,
)
@ -3733,6 +3733,7 @@ class FastAPI(Starlette):
"""
),
],
*args: Any,
response_model: Annotated[
Any,
Doc(
@ -4051,7 +4052,6 @@ class FastAPI(Starlette):
"""
),
] = Default(generate_unique_id),
# *args,
**kwargs: Any
) -> Callable[[DecoratedCallable], DecoratedCallable]:
"""

10
fastapi/routing.py

@ -962,6 +962,7 @@ class APIRouter(routing.Router):
self.add_api_route(
path,
func,
*args,
response_model=response_model,
status_code=status_code,
tags=tags,
@ -985,7 +986,6 @@ class APIRouter(routing.Router):
callbacks=callbacks,
openapi_extra=openapi_extra,
generate_unique_id_function=generate_unique_id_function,
*args,
**kwargs,
)
return func
@ -1273,6 +1273,7 @@ class APIRouter(routing.Router):
self.add_api_route(
prefix + route.path,
route.endpoint,
*args,
response_model=route.response_model,
status_code=route.status_code,
tags=current_tags,
@ -1299,7 +1300,6 @@ class APIRouter(routing.Router):
callbacks=current_callbacks,
openapi_extra=route.openapi_extra,
generate_unique_id_function=current_generate_unique_id,
*args,
**kwargs
)
elif isinstance(route, routing.Route):
@ -1685,6 +1685,7 @@ class APIRouter(routing.Router):
"""
return self.api_route(
path,
*args,
response_model=response_model,
status_code=status_code,
tags=tags,
@ -1708,7 +1709,6 @@ class APIRouter(routing.Router):
callbacks=callbacks,
openapi_extra=openapi_extra,
generate_unique_id_function=generate_unique_id_function,
*args,
**kwargs,
)
@ -2070,6 +2070,7 @@ class APIRouter(routing.Router):
"""
return self.api_route(
path,
*args,
response_model=response_model,
status_code=status_code,
tags=tags,
@ -2093,7 +2094,6 @@ class APIRouter(routing.Router):
callbacks=callbacks,
openapi_extra=openapi_extra,
generate_unique_id_function=generate_unique_id_function,
*args,
**kwargs,
)
@ -2455,6 +2455,7 @@ class APIRouter(routing.Router):
"""
return self.api_route(
path,
*args,
response_model=response_model,
status_code=status_code,
tags=tags,
@ -2478,7 +2479,6 @@ class APIRouter(routing.Router):
callbacks=callbacks,
openapi_extra=openapi_extra,
generate_unique_id_function=generate_unique_id_function,
*args,
**kwargs,
)

3
tests/test_operations_signatures.py

@ -1,11 +1,8 @@
import inspect
import pytest
from fastapi import APIRouter, FastAPI
method_names = ["get", "put", "post", "delete", "options", "head", "patch", "trace"]
@pytest.mark.parametrize('method_name', ["get", "put", "post", "delete", "options", "head", "patch", "trace"])
@pytest.mark.parametrize('sig_param', inspect.signature(APIRouter.get).parameters.items())

Loading…
Cancel
Save