From 9634fa58b0db2703c45d13e366fe566f234d34a2 Mon Sep 17 00:00:00 2001 From: Sagar Vora <16315650+sagarvora@users.noreply.github.com> Date: Thu, 3 Jul 2025 17:52:17 +0530 Subject: [PATCH] refactor: define `annotations` earlier --- frappe/utils/typing_validations.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frappe/utils/typing_validations.py b/frappe/utils/typing_validations.py index b4ada1b50a..a6a1c8c097 100644 --- a/frappe/utils/typing_validations.py +++ b/frappe/utils/typing_validations.py @@ -93,15 +93,16 @@ def transform_parameter_types(func: Callable, args: tuple, kwargs: dict): defined on the function. """ + annotations = func.__annotations__ + if ( not (args or kwargs) - or not func.__annotations__ + or not annotations # No input validations to perform - or (len(func.__annotations__) == 1 and func.__annotations__.get("return")) + or (len(annotations) == 1 and "return" in annotations) ): return args, kwargs - annotations = func.__annotations__ new_args, new_kwargs = list(args), kwargs # generate kwargs dict from args