From 780509bdfdce3ce48c9ccf968c935a217ecd624e Mon Sep 17 00:00:00 2001 From: yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Sun, 22 Oct 2023 08:27:06 +0800 Subject: [PATCH] fix: `Union` parse error --- backend/funix/decorator/magic.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/funix/decorator/magic.py b/backend/funix/decorator/magic.py index 1f292c5..1d53a5c 100644 --- a/backend/funix/decorator/magic.py +++ b/backend/funix/decorator/magic.py @@ -167,12 +167,14 @@ def get_type_widget_prop( if function_arg_type_name in widget_type: widget = widget_type[function_arg_type_name] for single_widget_type in widget_type: - if function_annotation.__name__ == single_widget_type: - widget = widget_type[single_widget_type] - break + if hasattr(function_annotation, "__name__"): + if getattr(function_annotation, "__name__") == single_widget_type: + widget = widget_type[single_widget_type] + break if not widget: - if function_annotation.__name__ in builtin_widgets: - widget = builtin_widgets[function_annotation.__name__] + if hasattr(function_annotation, "__name__"): + if getattr(function_annotation, "__name__") in builtin_widgets: + widget = builtin_widgets[getattr(function_annotation, "__name__")] if widget and anal_result: anal_result["widget"] = widget