Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

ci: enable Ruff FURB152 (#44091)

Asuka Minato3b3edd53ce8c
diff --git a/api/.ruff.toml b/api/.ruff.toml
index c13e0fe4ff0..333c520d1c7 100644
--- a/api/.ruff.toml
+++ b/api/.ruff.toml
@@ -65,7 +65,6 @@ ignore = [
"F821", # undefined-name
"F841", # unused-variable
"FURB113", # repeated-append
- "FURB152", # math-constant
"UP007", # non-pep604-annotation
"UP032", # f-string
"B007", # unused-loop-control-variable
diff --git a/api/providers/trace/trace-tencent/tests/unit_tests/tencent_trace/test_client.py b/api/providers/trace/trace-tencent/tests/unit_tests/tencent_trace/test_client.py
index f0c2752ffec..aca90ec45ce 100644
--- a/api/providers/trace/trace-tencent/tests/unit_tests/tencent_trace/test_client.py
+++ b/api/providers/trace/trace-tencent/tests/unit_tests/tencent_trace/test_client.py
@@ -490,7 +490,7 @@ def test_create_and_export_span_converts_attribute_types(patch_core_components:
parent_span_id=None,
span_id=2,
name="span",
- attributes={"num": 5, "flag": True, "pi": 3.14, "text": "value"},
+ attributes={"num": 5, "flag": True, "pi": float("3.14"), "text": "value"},
events=[],
links=[],
status=Status(StatusCode.OK),
@@ -502,7 +502,7 @@ def test_create_and_export_span_converts_attribute_types(patch_core_components:
(attrs,) = span.set_attributes.call_args.args
assert attrs["num"] == 5
assert attrs["flag"] is True
- assert attrs["pi"] == 3.14
+ assert attrs["pi"] == float("3.14")
assert attrs["text"] == "value"
diff --git a/api/tests/unit_tests/controllers/service_api/app/test_conversation.py b/api/tests/unit_tests/controllers/service_api/app/test_conversation.py
index efb2c2566e2..2e8a6f5e1b6 100644
--- a/api/tests/unit_tests/controllers/service_api/app/test_conversation.py
+++ b/api/tests/unit_tests/controllers/service_api/app/test_conversation.py
@@ -279,8 +279,8 @@ class TestConversationVariableUpdatePayload:
def test_payload_with_float_value(self):
"""Test payload with float value."""
- payload = ConversationVariableUpdatePayload(value=3.14159)
- assert payload.value == 3.14159
+ payload = ConversationVariableUpdatePayload(value=float("3.14159"))
+ assert payload.value == float("3.14159")
def test_payload_with_list_value(self):
"""Test payload with list value."""
diff --git a/api/tests/unit_tests/core/app/apps/test_base_app_generator.py b/api/tests/unit_tests/core/app/apps/test_base_app_generator.py
index 2aff04a7471..e24fb7560fb 100644
--- a/api/tests/unit_tests/core/app/apps/test_base_app_generator.py
+++ b/api/tests/unit_tests/core/app/apps/test_base_app_generator.py
@@ -189,7 +189,7 @@ def test_validate_inputs_with_default_value():
label="test_number_float",
type=VariableEntityType.NUMBER,
required=False,
- default=3.14,
+ default=float("3.14"),
)
result = base_app_generator._validate_inputs(
@@ -197,7 +197,7 @@ def test_validate_inputs_with_default_value():
value=None,
)
- assert result == 3.14
+ assert result == float("3.14")
# Test with number default value as string (frontend sends as string)
var_number_string = VariableEntity(
diff --git a/api/tests/unit_tests/core/mcp/server/test_streamable_http.py b/api/tests/unit_tests/core/mcp/server/test_streamable_http.py
index 32df2a8a9b0..3667d7a8f5e 100644
--- a/api/tests/unit_tests/core/mcp/server/test_streamable_http.py
+++ b/api/tests/unit_tests/core/mcp/server/test_streamable_http.py
@@ -780,7 +780,7 @@ class TestUtilityFunctions:
jsonschema.Draft202012Validator.check_schema(schema)
# 2) Validate instances with all types
- jsonschema.validate(instance={"count": 3.14, "name": "alice"}, schema=schema)
+ jsonschema.validate(instance={"count": float("3.14"), "name": "alice"}, schema=schema)
jsonschema.validate(
instance={"count": 2, "enabled": True, "metadata": {"key": "val"}},
schema=schema,
diff --git a/api/tests/unit_tests/core/moderation/test_sensitive_word_filter.py b/api/tests/unit_tests/core/moderation/test_sensitive_word_filter.py
index 3abb42ecf17..e8232645fc4 100644
--- a/api/tests/unit_tests/core/moderation/test_sensitive_word_filter.py
+++ b/api/tests/unit_tests/core/moderation/test_sensitive_word_filter.py
@@ -1011,7 +1011,7 @@ class TestComplexInputTypes:
moderation = self._create_moderation("3.14")
# Float should be converted to string for matching
- result = moderation.moderation_for_inputs({"pi": 3.14159})
+ result = moderation.moderation_for_inputs({"pi": float("3.14159")})
assert result.flagged is True
def test_negative_numbers(self) -> None:
diff --git a/api/tests/unit_tests/core/schemas/test_resolver.py b/api/tests/unit_tests/core/schemas/test_resolver.py
index a08ad424273..1a46e235386 100644
--- a/api/tests/unit_tests/core/schemas/test_resolver.py
+++ b/api/tests/unit_tests/core/schemas/test_resolver.py
@@ -203,7 +203,7 @@ class TestSchemaResolver:
assert resolve_dify_schema_refs(123) == 123
assert resolve_dify_schema_refs(True) is True
assert resolve_dify_schema_refs(None) is None
- assert resolve_dify_schema_refs(3.14) == 3.14
+ assert resolve_dify_schema_refs(float("3.14")) == float("3.14")
def test_cache_functionality(self) -> None:
"""Test that caching works correctly"""
diff --git a/api/tests/unit_tests/core/tools/utils/test_tool_engine_serialization.py b/api/tests/unit_tests/core/tools/utils/test_tool_engine_serialization.py
index da699ef6101..24821ea85bf 100644
--- a/api/tests/unit_tests/core/tools/utils/test_tool_engine_serialization.py
+++ b/api/tests/unit_tests/core/tools/utils/test_tool_engine_serialization.py
@@ -83,16 +83,16 @@ class TestSafeJsonValue:
assert result == [[1, 2], [3, 4]]
# Test array with float values
- test_float_array = np.array([1.5, 2.7, 3.14])
+ test_float_array = np.array([1.5, 2.7, float("3.14")])
result = safe_json_value(test_float_array)
- assert result == [1.5, 2.7, 3.14]
+ assert result == [1.5, 2.7, float("3.14")]
def test_dict_conversion(self):
"""Test dictionary conversion using safe_json_dict"""
test_dict = {
"string": "value",
"number": 42,
- "float": 3.14,
+ "float": float("3.14"),
"boolean": True,
"list": [1, 2, 3],
"nested": {"key": "value"},
@@ -106,7 +106,7 @@ class TestSafeJsonValue:
test_list = [
"string",
42,
- 3.14,
+ float("3.14"),
True,
[1, 2, 3],
{"key": "value"},
@@ -123,27 +123,27 @@ class TestSafeJsonValue:
def test_tuple_conversion(self):
"""Test tuple conversion to list"""
- test_tuple = (1, "string", 3.14)
+ test_tuple = (1, "string", float("3.14"))
result = safe_json_value(test_tuple)
assert isinstance(result, list)
- assert result == [1, "string", 3.14]
+ assert result == [1, "string", float("3.14")]
def test_set_conversion(self):
"""Test set conversion to list"""
- test_set = {1, "string", 3.14}
+ test_set = {1, "string", float("3.14")}
result = safe_json_value(test_set)
assert isinstance(result, list)
# Note: set order is not guaranteed, so we check length and content
assert len(result) == 3
assert 1 in result
assert "string" in result
- assert 3.14 in result
+ assert float("3.14") in result
def test_basic_types_passthrough(self):
"""Test that basic types are passed through unchanged"""
assert safe_json_value("string") == "string"
assert safe_json_value(42) == 42
- assert safe_json_value(3.14) == 3.14
+ assert safe_json_value(float("3.14")) == float("3.14")
assert safe_json_value(True) is True
assert safe_json_value(False) is False
assert safe_json_value(None) is None
diff --git a/api/tests/unit_tests/core/tools/workflow_as_tool/test_tool.py b/api/tests/unit_tests/core/tools/workflow_as_tool/test_tool.py
index ccb70e43a45..ba4fb38fbd0 100644
--- a/api/tests/unit_tests/core/tools/workflow_as_tool/test_tool.py
+++ b/api/tests/unit_tests/core/tools/workflow_as_tool/test_tool.py
@@ -538,7 +538,7 @@ def test_workflow_tool_should_handle_empty_outputs(
[
("string_var", "test string"),
("int_var", 42),
- ("float_var", 3.14),
+ ("float_var", float("3.14")),
("bool_var", True),
("list_var", [1, 2, 3]),
("dict_var", {"key": "value"}),
diff --git a/api/tests/unit_tests/core/variables/test_segment.py b/api/tests/unit_tests/core/variables/test_segment.py
index 38cbf0adc96..fe7a61e1168 100644
--- a/api/tests/unit_tests/core/variables/test_segment.py
+++ b/api/tests/unit_tests/core/variables/test_segment.py
@@ -191,10 +191,10 @@ class TestSegmentDumpAndLoad:
NoneSegment(),
StringSegment(value="test string"),
IntegerSegment(value=42),
- FloatSegment(value=3.14),
+ FloatSegment(value=float("3.14")),
ObjectSegment(value={"key": "value", "number": 123}),
FileSegment(value=test_file),
- ArrayAnySegment(value=[1, "string", 3.14, {"key": "value"}]),
+ ArrayAnySegment(value=[1, "string", float("3.14"), {"key": "value"}]),
ArrayStringSegment(value=["hello", "world"]),
ArrayNumberSegment(value=[1, 2.5, 3]),
ArrayObjectSegment(value=[{"id": 1}, {"id": 2}]),
@@ -233,10 +233,10 @@ class TestSegmentDumpAndLoad:
NoneVariable(name="none_var"),
StringVariable(value="test string", name="string_var"),
IntegerVariable(value=42, name="int_var"),
- FloatVariable(value=3.14, name="float_var"),
+ FloatVariable(value=float("3.14"), name="float_var"),
ObjectVariable(value={"key": "value", "number": 123}, name="object_var"),
FileVariable(value=test_file, name="file_var"),
- ArrayAnyVariable(value=[1, "string", 3.14, {"key": "value"}], name="array_any_var"),
+ ArrayAnyVariable(value=[1, "string", float("3.14"), {"key": "value"}], name="array_any_var"),
ArrayStringVariable(value=["hello", "world"], name="array_string_var"),
ArrayNumberVariable(value=[1, 2.5, 3], name="array_number_var"),
ArrayObjectVariable(value=[{"id": 1}, {"id": 2}], name="array_object_var"),
diff --git a/api/tests/unit_tests/core/variables/test_segment_type_validation.py b/api/tests/unit_tests/core/variables/test_segment_type_validation.py
index bb294ba3904..dcc928c2b05 100644
--- a/api/tests/unit_tests/core/variables/test_segment_type_validation.py
+++ b/api/tests/unit_tests/core/variables/test_segment_type_validation.py
@@ -97,8 +97,8 @@ def get_number_cases() -> list[ValidationTestCase]:
ValidationTestCase(SegmentType.NUMBER, 42, True, "Positive integer"),
ValidationTestCase(SegmentType.NUMBER, -42, True, "Negative integer"),
ValidationTestCase(SegmentType.NUMBER, 0, True, "Zero integer"),
- ValidationTestCase(SegmentType.NUMBER, 3.14, True, "Positive float"),
- ValidationTestCase(SegmentType.NUMBER, -3.14, True, "Negative float"),
+ ValidationTestCase(SegmentType.NUMBER, float("3.14"), True, "Positive float"),
+ ValidationTestCase(SegmentType.NUMBER, -float("3.14"), True, "Negative float"),
ValidationTestCase(SegmentType.NUMBER, 0.0, True, "Zero float"),
ValidationTestCase(SegmentType.NUMBER, float("inf"), True, "Positive infinity"),
ValidationTestCase(SegmentType.NUMBER, float("-inf"), True, "Negative infinity"),
@@ -122,7 +122,7 @@ def get_string_cases() -> list[ValidationTestCase]:
ValidationTestCase(SegmentType.STRING, "line1\nline2", True, "Multiline string"),
# invalid values
ValidationTestCase(SegmentType.STRING, 123, False, "Integer"),
- ValidationTestCase(SegmentType.STRING, 3.14, False, "Float"),
+ ValidationTestCase(SegmentType.STRING, float("3.14"), False, "Float"),
ValidationTestCase(SegmentType.STRING, True, False, "Boolean"),
ValidationTestCase(SegmentType.STRING, None, False, "None value"),
ValidationTestCase(SegmentType.STRING, [], False, "Empty list"),
@@ -143,7 +143,7 @@ def get_object_cases() -> list[ValidationTestCase]:
# invalid cases
ValidationTestCase(SegmentType.OBJECT, "not a dict", False, "String"),
ValidationTestCase(SegmentType.OBJECT, 123, False, "Integer"),
- ValidationTestCase(SegmentType.OBJECT, 3.14, False, "Float"),
+ ValidationTestCase(SegmentType.OBJECT, float("3.14"), False, "Float"),
ValidationTestCase(SegmentType.OBJECT, True, False, "Boolean"),
ValidationTestCase(SegmentType.OBJECT, None, False, "None value"),
ValidationTestCase(SegmentType.OBJECT, [], False, "Empty list"),
@@ -161,7 +161,7 @@ def get_secret_cases() -> list[ValidationTestCase]:
ValidationTestCase(SegmentType.SECRET, "very_long_secret_key_with_special_chars!@#", True, "Complex secret"),
# invalid cases
ValidationTestCase(SegmentType.SECRET, 123, False, "Integer"),
- ValidationTestCase(SegmentType.SECRET, 3.14, False, "Float"),
+ ValidationTestCase(SegmentType.SECRET, float("3.14"), False, "Float"),
ValidationTestCase(SegmentType.SECRET, True, False, "Boolean"),
ValidationTestCase(SegmentType.SECRET, None, False, "None value"),
ValidationTestCase(SegmentType.SECRET, [], False, "Empty list"),
@@ -254,21 +254,21 @@ def get_array_any_validation_cases() -> list[ArrayValidationTestCase]:
return [
ArrayValidationTestCase(
SegmentType.ARRAY_ANY,
- [1, "string", 3.14, {"key": "value"}, True],
+ [1, "string", float("3.14"), {"key": "value"}, True],
ArrayValidation.NONE,
True,
"Mixed types with NONE validation",
),
ArrayValidationTestCase(
SegmentType.ARRAY_ANY,
- [1, "string", 3.14, {"key": "value"}, True],
+ [1, "string", float("3.14"), {"key": "value"}, True],
ArrayValidation.FIRST,
True,
"Mixed types with FIRST validation",
),
ArrayValidationTestCase(
SegmentType.ARRAY_ANY,
- [1, "string", 3.14, {"key": "value"}, True],
+ [1, "string", float("3.14"), {"key": "value"}, True],
ArrayValidation.ALL,
True,
"Mixed types with ALL validation",
@@ -366,7 +366,11 @@ def get_array_number_validation_cases() -> list[ArrayValidationTestCase]:
SegmentType.ARRAY_NUMBER, ["not a number", 42], ArrayValidation.FIRST, False, "First invalid"
),
ArrayValidationTestCase(
- SegmentType.ARRAY_NUMBER, [3.14, 2.71, 1.41], ArrayValidation.FIRST, True, "All valid floats"
+ SegmentType.ARRAY_NUMBER,
+ [float("3.14"), float("2.71"), 1.41],
+ ArrayValidation.FIRST,
+ True,
+ "All valid floats",
),
# ALL strategy
ArrayValidationTestCase(
@@ -566,7 +570,7 @@ class TestSegmentTypeIsValid:
elif segment_type in {SegmentType.NUMBER, SegmentType.INTEGER}:
test_value = 42
elif segment_type == SegmentType.FLOAT:
- test_value = 3.14
+ test_value = float("3.14")
elif segment_type == SegmentType.BOOLEAN:
test_value = True
elif segment_type == SegmentType.OBJECT:
@@ -614,7 +618,7 @@ class TestSegmentTypeArrayValidation:
non_list_values = [
"not a list",
123,
- 3.14,
+ float("3.14"),
True,
None,
{"key": "value"},
@@ -827,7 +831,7 @@ class TestSegmentTypeValidationIntegration:
# Number type should accept both integers and floats, including booleans (since bool is subclass of int)
assert SegmentType.NUMBER.is_valid(42) is True
- assert SegmentType.NUMBER.is_valid(3.14) is True
+ assert SegmentType.NUMBER.is_valid(float("3.14")) is True
assert SegmentType.NUMBER.is_valid(True) is True # bool is subclass of int
assert SegmentType.NUMBER.is_valid(False) is True # bool is subclass of int
diff --git a/api/tests/unit_tests/core/variables/test_variables.py b/api/tests/unit_tests/core/variables/test_variables.py
index 417db78cc8f..31759808755 100644
--- a/api/tests/unit_tests/core/variables/test_variables.py
+++ b/api/tests/unit_tests/core/variables/test_variables.py
@@ -23,9 +23,9 @@ def test_frozen_variables() -> None:
with pytest.raises(ValidationError):
int_var.value = 100 # pyrefly: ignore[read-only]
- float_var = FloatVariable(name="float", value=3.14)
+ float_var = FloatVariable(name="float", value=float("3.14"))
with pytest.raises(ValidationError):
- float_var.value = 2.718 # pyrefly: ignore[read-only]
+ float_var.value = float("2.718") # pyrefly: ignore[read-only]
secret_var = SecretVariable(name="secret", value="secret_value")
with pytest.raises(ValidationError):
@@ -43,7 +43,7 @@ def test_variable_value_type_immutable() -> None:
with pytest.raises(ValidationError):
IntegerVariable(value_type=SegmentType.ARRAY_ANY, name=var.name, value=var.value)
- var = FloatVariable(name="float", value=3.14)
+ var = FloatVariable(name="float", value=float("3.14"))
with pytest.raises(ValidationError):
FloatVariable(value_type=SegmentType.ARRAY_ANY, name=var.name, value=var.value)
@@ -80,8 +80,8 @@ def test_variable_to_object() -> None:
assert var.to_object() == "text"
var = IntegerVariable(name="integer", value=42)
assert var.to_object() == 42
- var = FloatVariable(name="float", value=3.14)
- assert var.to_object() == 3.14
+ var = FloatVariable(name="float", value=float("3.14"))
+ assert var.to_object() == float("3.14")
var = SecretVariable(name="secret", value="secret_value")
assert var.to_object() == "secret_value"
diff --git a/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_output_type_checker.py b/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_output_type_checker.py
index b2fbc4371b1..1748ebd42f0 100644
--- a/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_output_type_checker.py
+++ b/api/tests/unit_tests/core/workflow/nodes/agent_v2/test_output_type_checker.py
@@ -75,7 +75,7 @@ def test_all_scalar_types_ready_on_correct_payload() -> None:
DeclaredOutputConfig(name="b", type=DeclaredOutputType.BOOLEAN),
DeclaredOutputConfig(name="o", type=DeclaredOutputType.OBJECT),
]
- payload = {"s": "hello", "n": 3.14, "b": True, "o": {"k": "v"}}
+ payload = {"s": "hello", "n": float("3.14"), "b": True, "o": {"k": "v"}}
outcome = checker.check(declared_outputs=declared, raw_output=payload, tenant_id="t-1")
diff --git a/api/tests/unit_tests/core/workflow/nodes/code/code_node_spec.py b/api/tests/unit_tests/core/workflow/nodes/code/code_node_spec.py
index 01018555c0b..2a1c40d77c2 100644
--- a/api/tests/unit_tests/core/workflow/nodes/code/code_node_spec.py
+++ b/api/tests/unit_tests/core/workflow/nodes/code/code_node_spec.py
@@ -161,9 +161,9 @@ class TestCodeNodeCheckMethods:
def test_check_number_float_value(self):
"""Test _check_number with float value."""
node = CodeNode.__new__(CodeNode)
- result = node._check_number(3.14, "test_var")
+ result = node._check_number(float("3.14"), "test_var")
- assert result == 3.14
+ assert result == float("3.14")
def test_check_number_zero(self):
"""Test _check_number with zero."""
@@ -182,9 +182,9 @@ class TestCodeNodeCheckMethods:
def test_check_number_negative_float(self):
"""Test _check_number with negative float."""
node = CodeNode.__new__(CodeNode)
- result = node._check_number(-3.14159, "test_var")
+ result = node._check_number(-float("3.14159"), "test_var")
- assert result == -3.14159
+ assert result == -float("3.14159")
class TestCodeNodeConvertBooleanToInt:
@@ -218,9 +218,9 @@ class TestCodeNodeConvertBooleanToInt:
def test_convert_float_returns_same(self):
"""Test converting float returns same value."""
- result = CodeNode._convert_boolean_to_int(3.14)
+ result = CodeNode._convert_boolean_to_int(float("3.14"))
- assert result == 3.14
+ assert result == float("3.14")
def test_convert_zero_returns_zero(self):
"""Test converting zero returns zero."""
diff --git a/api/tests/unit_tests/enterprise/telemetry/test_exporter.py b/api/tests/unit_tests/enterprise/telemetry/test_exporter.py
index b0c1ef13b95..35bee1880de 100644
--- a/api/tests/unit_tests/enterprise/telemetry/test_exporter.py
+++ b/api/tests/unit_tests/enterprise/telemetry/test_exporter.py
@@ -539,12 +539,12 @@ def test_record_histogram_calls_record_on_histogram() -> None:
labels = {"tenant_id": "t1"}
with _running_exporter(_make_grpc_config()) as exporter:
exporter._histograms[EnterpriseTelemetryHistogram.WORKFLOW_DURATION] = histogram
- exporter.record_histogram(EnterpriseTelemetryHistogram.WORKFLOW_DURATION, 3.14, labels)
+ exporter.record_histogram(EnterpriseTelemetryHistogram.WORKFLOW_DURATION, float("3.14"), labels)
metrics = reader.get_metrics_data().resource_metrics[0].scope_metrics[0].metrics
data_point = metrics[0].data.data_points[0]
assert data_point.count == 1
- assert data_point.sum == 3.14
+ assert data_point.sum == float("3.14")
assert dict(data_point.attributes) == labels
provider.shutdown()
diff --git a/api/tests/unit_tests/factories/test_variable_factory.py b/api/tests/unit_tests/factories/test_variable_factory.py
index 00847bb058f..0f6569b6133 100644
--- a/api/tests/unit_tests/factories/test_variable_factory.py
+++ b/api/tests/unit_tests/factories/test_variable_factory.py
@@ -52,7 +52,7 @@ def test_integer_variable() -> None:
def test_float_variable() -> None:
- test_data = {"value_type": "number", "name": "test_float", "value": 3.14}
+ test_data = {"value_type": "number", "name": "test_float", "value": float("3.14")}
result = variable_factory.build_conversation_variable_from_mapping(test_data)
assert isinstance(result, FloatVariable)
@@ -350,7 +350,7 @@ def test_build_segment_array_file_empty_list() -> None:
def test_build_segment_array_any_mixed_types() -> None:
"""Test building ArrayAnySegment from list with mixed types."""
- mixed_values = ["string", 42, 3.14, {"key": "value"}, None]
+ mixed_values = ["string", 42, float("3.14"), {"key": "value"}, None]
segment = variable_factory.build_segment(mixed_values)
assert isinstance(segment, ArrayAnySegment)
assert segment.value == mixed_values
@@ -624,9 +624,9 @@ class TestBuildSegmentWithType:
def test_number_type_float(self) -> None:
"""Test building a number segment with float value."""
- result = build_segment_with_type(SegmentType.NUMBER, 3.14)
+ result = build_segment_with_type(SegmentType.NUMBER, float("3.14"))
assert isinstance(result, FloatSegment)
- assert result.value == 3.14
+ assert result.value == float("3.14")
assert result.value_type == SegmentType.FLOAT
def test_object_type(self) -> None:
@@ -707,9 +707,9 @@ class TestBuildSegmentWithType:
assert result.value_type == SegmentType.ARRAY_STRING
# Array of numbers
- result = build_segment_with_type(SegmentType.ARRAY_NUMBER, [1, 2, 3.14])
+ result = build_segment_with_type(SegmentType.ARRAY_NUMBER, [1, 2, float("3.14")])
assert isinstance(result, ArrayNumberSegment)
- assert result.value == [1, 2, 3.14]
+ assert result.value == [1, 2, float("3.14")]
assert result.value_type == SegmentType.ARRAY_NUMBER
# Array of objects
@@ -766,7 +766,7 @@ class TestBuildSegmentWithType:
assert result_int.value_type == SegmentType.INTEGER
# Float should work
- result_float = build_segment_with_type(SegmentType.NUMBER, 3.14)
+ result_float = build_segment_with_type(SegmentType.NUMBER, float("3.14"))
assert isinstance(result_float, FloatSegment)
assert result_float.value_type == SegmentType.FLOAT
@@ -775,7 +775,7 @@ class TestBuildSegmentWithType:
[
(SegmentType.STRING, "test", StringSegment),
(SegmentType.INTEGER, 42, IntegerSegment),
- (SegmentType.FLOAT, 3.14, FloatSegment),
+ (SegmentType.FLOAT, float("3.14"), FloatSegment),
(SegmentType.OBJECT, {}, ObjectSegment),
(SegmentType.NONE, None, NoneSegment),
(SegmentType.ARRAY_STRING, [], ArrayStringSegment),
diff --git a/api/tests/unit_tests/libs/test_passport.py b/api/tests/unit_tests/libs/test_passport.py
index 060ecfa5ce1..3adcf7a79fe 100644
--- a/api/tests/unit_tests/libs/test_passport.py
+++ b/api/tests/unit_tests/libs/test_passport.py
@@ -42,7 +42,7 @@ class TestPassportService:
test_cases = [
{"string": "value"},
{"number": 42},
- {"float": 3.14},
+ {"float": float("3.14")},
{"boolean": True},
{"null": None},
{"array": [1, 2, 3]},
diff --git a/api/tests/unit_tests/models/test_workflow.py b/api/tests/unit_tests/models/test_workflow.py
index 4e77e3e80cb..c8d213b75d0 100644
--- a/api/tests/unit_tests/models/test_workflow.py
+++ b/api/tests/unit_tests/models/test_workflow.py
@@ -44,7 +44,7 @@ def test_environment_variables():
variable1 = StringVariable(name="var1", value="value1", id=str(uuid4()), selector=["env", "var1"])
variable2 = IntegerVariable(name="var2", value=123, id=str(uuid4()), selector=["env", "var2"])
variable3 = SecretVariable(name="var3", value="secret", id=str(uuid4()), selector=["env", "var3"])
- variable4 = FloatVariable(name="var4", value=3.14, id=str(uuid4()), selector=["env", "var4"])
+ variable4 = FloatVariable(name="var4", value=float("3.14"), id=str(uuid4()), selector=["env", "var4"])
with (
mock.patch("core.helper.encrypter.encrypt_token", return_value="encrypted_token"),
@@ -110,7 +110,7 @@ def test_update_environment_variables():
selector=["env", "var3"],
description="old description",
)
- variable4 = FloatVariable(name="var4", value=3.14, id=str(uuid4()), selector=["env", "var4"])
+ variable4 = FloatVariable(name="var4", value=float("3.14"), id=str(uuid4()), selector=["env", "var4"])
with (
mock.patch("core.helper.encrypter.encrypt_token", return_value="encrypted_token"),
diff --git a/api/tests/unit_tests/services/test_webhook_service_additional.py b/api/tests/unit_tests/services/test_webhook_service_additional.py
index 9bf7f9d50b6..c4197b575fa 100644
--- a/api/tests/unit_tests/services/test_webhook_service_additional.py
+++ b/api/tests/unit_tests/services/test_webhook_service_additional.py
@@ -162,7 +162,7 @@ class TestWebhookServiceValidationAndConversion:
("raw_value", "param_type", "expected"),
[
("42", SegmentType.NUMBER, 42),
- ("3.14", SegmentType.NUMBER, 3.14),
+ ("3.14", SegmentType.NUMBER, float("3.14")),
("yes", SegmentType.BOOLEAN, True),
("no", SegmentType.BOOLEAN, False),
],
diff --git a/api/tests/unit_tests/utils/encryption/test_system_encryption.py b/api/tests/unit_tests/utils/encryption/test_system_encryption.py
index 8623b3edcc8..327847e1e32 100644
--- a/api/tests/unit_tests/utils/encryption/test_system_encryption.py
+++ b/api/tests/unit_tests/utils/encryption/test_system_encryption.py
@@ -565,7 +565,7 @@ class TestEdgeCases:
params = {
"string": "test_string",
"integer": 42,
- "float": 3.14159,
+ "float": float("3.14159"),
"boolean_true": True,
"boolean_false": False,
"null_value": None,