From 8e5d327aca80d9c0fa84c9aefcddef77fed37ea9 Mon Sep 17 00:00:00 2001 From: svlandeg Date: Fri, 13 Mar 2026 10:18:40 +0100 Subject: [PATCH] fix return type of eval_type --- fastapi/_compat/v2.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastapi/_compat/v2.py b/fastapi/_compat/v2.py index 6cf5c67f7c..d075c49822 100644 --- a/fastapi/_compat/v2.py +++ b/fastapi/_compat/v2.py @@ -42,9 +42,9 @@ Undefined = PydanticUndefined def define_forwardref() -> Callable[..., Any]: # eval_type_lenient has been deprecated since Pydantic v2.10.0b1 (PR #10530) - eval_type = getattr(_pydantic_typing_extra, "try_eval_type", None) - if eval_type is not None: - return cast(Callable[..., Any], eval_type) + try_eval_type = getattr(_pydantic_typing_extra, "try_eval_type", None) + if try_eval_type is not None: + return lambda *args: try_eval_type(*args)[0] return _pydantic_typing_extra.eval_type_lenient