From 80e00439b8bddc5fe02f5754ad554a33b5c4713f Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Tue, 18 Mar 2025 16:38:41 +0800 Subject: [PATCH] fix: The float values collected by the form will be treated as ints when the decimal part is 0, resulting in a type error --- .../function_lib_node/impl/base_function_lib_node.py | 8 ++++++-- .../step_node/function_node/impl/base_function_node.py | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/application/flow/step_node/function_lib_node/impl/base_function_lib_node.py b/apps/application/flow/step_node/function_lib_node/impl/base_function_lib_node.py index ce13890981c..506b1526cc9 100644 --- a/apps/application/flow/step_node/function_lib_node/impl/base_function_lib_node.py +++ b/apps/application/flow/step_node/function_lib_node/impl/base_function_lib_node.py @@ -45,9 +45,9 @@ def get_field_value(debug_field_list, name, is_required): def valid_reference_value(_type, value, name): if _type == 'int': - instance_type = int + instance_type = int | float elif _type == 'float': - instance_type = float + instance_type = float | int elif _type == 'dict': instance_type = dict elif _type == 'array': @@ -70,6 +70,10 @@ def convert_value(name: str, value, _type, is_required, source, node): value[0], value[1:]) valid_reference_value(_type, value, name) + if _type == 'int': + return int(value) + if _type == 'float': + return float(value) return value try: if _type == 'int': diff --git a/apps/application/flow/step_node/function_node/impl/base_function_node.py b/apps/application/flow/step_node/function_node/impl/base_function_node.py index 12e07927ae5..4a5c75c8132 100644 --- a/apps/application/flow/step_node/function_node/impl/base_function_node.py +++ b/apps/application/flow/step_node/function_node/impl/base_function_node.py @@ -33,9 +33,9 @@ def write_context(step_variable: Dict, global_variable: Dict, node, workflow): def valid_reference_value(_type, value, name): if _type == 'int': - instance_type = int + instance_type = int | float elif _type == 'float': - instance_type = float + instance_type = float | int elif _type == 'dict': instance_type = dict elif _type == 'array': @@ -56,6 +56,10 @@ def convert_value(name: str, value, _type, is_required, source, node): value[0], value[1:]) valid_reference_value(_type, value, name) + if _type == 'int': + return int(value) + if _type == 'float': + return float(value) return value try: if _type == 'int':