Browse Source

🎨 Auto format

pull/15508/head
pre-commit-ci-lite[bot] 3 weeks ago
committed by GitHub
parent
commit
cbf5fe4d04
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      fastapi/routing.py
  2. 10
      tests/test_custom_route_class.py

8
fastapi/routing.py

@ -1412,12 +1412,8 @@ class APIRouter(routing.Router):
"openapi_extra": openapi_extra,
"generate_unique_id_function": current_generate_unique_id,
}
if (
"strict_content_type" in route_init_params
or any(
p.kind == inspect.Parameter.VAR_KEYWORD
for p in route_init_params.values()
)
if "strict_content_type" in route_init_params or any(
p.kind == inspect.Parameter.VAR_KEYWORD for p in route_init_params.values()
):
route_kwargs["strict_content_type"] = get_value_or_default(
strict_content_type, self.strict_content_type

10
tests/test_custom_route_class.py

@ -1,6 +1,6 @@
from collections.abc import Sequence
from collections.abc import Callable, Sequence
from enum import Enum
from typing import Any, Callable
from typing import Any
import pytest
from fastapi import APIRouter, FastAPI, params
@ -128,6 +128,7 @@ def test_openapi_schema():
}
)
def test_custom_api_route_without_strict_content_type():
"""
Regression test for #15503:
@ -212,6 +213,7 @@ def test_custom_api_route_without_strict_content_type():
assert response.status_code == 200
assert response.json() == {"ok": True}
def test_custom_api_route_with_kwargs():
"""
Custom APIRoute classes using **kwargs should still receive
@ -219,7 +221,9 @@ def test_custom_api_route_with_kwargs():
"""
class KwargsRoute(APIRoute):
def __init__(self, path: str, endpoint: Callable[..., Any], **kwargs: Any) -> None:
def __init__(
self, path: str, endpoint: Callable[..., Any], **kwargs: Any
) -> None:
super().__init__(path, endpoint, **kwargs)
app_kwargs = FastAPI()

Loading…
Cancel
Save