From 0dd1d0a80700eff421ddac9d78c0d349febd4e75 Mon Sep 17 00:00:00 2001 From: Jan Vollmer Date: Thu, 18 Dec 2025 21:18:17 +0100 Subject: [PATCH] add missing return statement Signed-off-by: Jan Vollmer --- fastapi/routing.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index c2fe80e030..d99c4526da 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -675,7 +675,7 @@ class APIRoute(routing.Route): @cached_property def response_fields(self) -> dict[Union[int, str], ModelField]: - response_fields = {} + response_fields: dict[Union[int, str], ModelField] = {} for additional_status_code, response in self.responses.items(): assert isinstance(response, dict), "An additional response must be a dict" model = response.get("model") @@ -688,10 +688,8 @@ class APIRoute(routing.Route): name=response_name, type_=model, mode="serialization" ) response_fields[additional_status_code] = response_field - if response_fields: - self.response_fields: dict[Union[int, str], ModelField] = response_fields - else: - self.response_fields = {} + + return response_fields @cached_property def dependant(self) -> Dependant: