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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(api): enable strict typing for small excluded test files (#44814)
Felix Shibc989a63eaef
diff --git a/api/tests/unit_tests/core/app/apps/test_exc.py b/api/tests/unit_tests/core/app/apps/test_exc.pyindex e41c78e89e3..4a35313fa6d 100644--- a/api/tests/unit_tests/core/app/apps/test_exc.py+++ b/api/tests/unit_tests/core/app/apps/test_exc.py@@ -2,6 +2,6 @@ from core.app.apps.exc import GenerateTaskStoppedErrorclass TestAppsExceptions:- def test_generate_task_stopped_error(self):+ def test_generate_task_stopped_error(self) -> None:err = GenerateTaskStoppedError("stopped")assert str(err) == "stopped"diff --git a/api/tests/unit_tests/core/app/apps/workflow/test_errors.py b/api/tests/unit_tests/core/app/apps/workflow/test_errors.pyindex 7461e068332..59b5303255c 100644--- a/api/tests/unit_tests/core/app/apps/workflow/test_errors.py+++ b/api/tests/unit_tests/core/app/apps/workflow/test_errors.py@@ -2,8 +2,9 @@ from core.app.apps.workflow.errors import WorkflowPausedInBlockingModeErrorclass TestWorkflowErrors:- def test_workflow_paused_in_blocking_mode_error_attributes(self):+ def test_workflow_paused_in_blocking_mode_error_attributes(self) -> None:err = WorkflowPausedInBlockingModeError()assert err.error_code == "workflow_paused_in_blocking_mode"assert err.code == 400+ assert err.description is not Noneassert "blocking response mode" in err.descriptiondiff --git a/api/tests/unit_tests/core/app/task_pipeline/test_exc.py b/api/tests/unit_tests/core/app/task_pipeline/test_exc.pyindex 9ea7e96e73d..dbeeff8655b 100644--- a/api/tests/unit_tests/core/app/task_pipeline/test_exc.py+++ b/api/tests/unit_tests/core/app/task_pipeline/test_exc.py@@ -2,10 +2,10 @@ from core.app.task_pipeline.exc import RecordNotFoundError, WorkflowRunNotFoundEclass TestTaskPipelineExceptions:- def test_record_not_found_error_message(self):+ def test_record_not_found_error_message(self) -> None:err = RecordNotFoundError("Message", "msg-1")assert str(err) == "Message with id msg-1 not found"- def test_workflow_run_not_found_error_message(self):+ def test_workflow_run_not_found_error_message(self) -> None:err = WorkflowRunNotFoundError("run-1")assert str(err) == "WorkflowRun with id run-1 not found"diff --git a/api/tests/unit_tests/core/plugin/impl/test_debugging.py b/api/tests/unit_tests/core/plugin/impl/test_debugging.pyindex 05959207b1a..4a747c77ad2 100644--- a/api/tests/unit_tests/core/plugin/impl/test_debugging.py+++ b/api/tests/unit_tests/core/plugin/impl/test_debugging.py@@ -6,7 +6,7 @@ from core.plugin.impl.debugging import PluginDebuggingClientclass TestPluginDebuggingClient:- def test_get_debugging_key(self, mocker: MockerFixture):+ def test_get_debugging_key(self, mocker: MockerFixture) -> None:client = PluginDebuggingClient()request_mock = mocker.patch.object(client,diff --git a/api/tests/unit_tests/core/rag/extractor/test_html_extractor.py b/api/tests/unit_tests/core/rag/extractor/test_html_extractor.pyindex c1c675e0d45..3437351c8dd 100644--- a/api/tests/unit_tests/core/rag/extractor/test_html_extractor.py+++ b/api/tests/unit_tests/core/rag/extractor/test_html_extractor.py@@ -4,7 +4,7 @@ from core.rag.extractor.html_extractor import HtmlExtractorclass TestHtmlExtractor:- def test_extract_returns_text_content(self, tmp_path: Path):+ def test_extract_returns_text_content(self, tmp_path: Path) -> None:file_path = tmp_path / "sample.html"file_path.write_text("<html><body><h1>Title</h1><p>Hello</p></body></html>", encoding="utf-8")@@ -14,7 +14,7 @@ class TestHtmlExtractor:assert len(docs) == 1assert "".join(docs[0].page_content.split()) == "TitleHello"- def test_load_as_text_strips_whitespace_and_handles_empty(self, tmp_path: Path):+ def test_load_as_text_strips_whitespace_and_handles_empty(self, tmp_path: Path) -> None:file_path = tmp_path / "sample.html"file_path.write_text("<html><body> \n </body></html>", encoding="utf-8")diff --git a/api/tests/unit_tests/core/trigger/utils/test_endpoint.py b/api/tests/unit_tests/core/trigger/utils/test_endpoint.pyindex e5879aea0a0..e90295335a5 100644--- a/api/tests/unit_tests/core/trigger/utils/test_endpoint.py+++ b/api/tests/unit_tests/core/trigger/utils/test_endpoint.py@@ -10,7 +10,7 @@ from core.trigger.utils import endpointclass TestGeneratePluginTriggerEndpointUrl:- def test_builds_correct_url(self):+ def test_builds_correct_url(self) -> None:with patch.object(endpoint, "base_url", URL("https://api.example.com")):url = endpoint.generate_plugin_trigger_endpoint_url("endpoint-123")@@ -18,13 +18,13 @@ class TestGeneratePluginTriggerEndpointUrl:class TestGenerateWebhookTriggerEndpoint:- def test_non_debug_url(self):+ def test_non_debug_url(self) -> None:with patch.object(endpoint, "base_url", URL("https://api.example.com")):url = endpoint.generate_webhook_trigger_endpoint("sub-456", debug=False)assert url == "https://api.example.com/triggers/webhook/sub-456"- def test_debug_url(self):+ def test_debug_url(self) -> None:with patch.object(endpoint, "base_url", URL("https://api.example.com")):url = endpoint.generate_webhook_trigger_endpoint("sub-456", debug=True)diff --git a/api/tests/unit_tests/core/trigger/utils/test_locks.py b/api/tests/unit_tests/core/trigger/utils/test_locks.pyindex 4fa202b1647..c4a0e6f5109 100644--- a/api/tests/unit_tests/core/trigger/utils/test_locks.py+++ b/api/tests/unit_tests/core/trigger/utils/test_locks.py@@ -2,18 +2,21 @@from __future__ import annotations-from core.trigger.utils.locks import build_trigger_refresh_lock_key, build_trigger_refresh_lock_keys+from core.trigger.utils.locks import (+ build_trigger_refresh_lock_key,+ build_trigger_refresh_lock_keys,+)class TestBuildTriggerRefreshLockKey:- def test_correct_format(self):+ def test_correct_format(self) -> None:key = build_trigger_refresh_lock_key("tenant-1", "sub-1")assert key == "trigger_provider_refresh_lock:tenant-1_sub-1"class TestBuildTriggerRefreshLockKeys:- def test_maps_over_pairs(self):+ def test_maps_over_pairs(self) -> None:pairs = [("t1", "s1"), ("t2", "s2")]keys = build_trigger_refresh_lock_keys(pairs)diff --git a/api/tests/unit_tests/libs/test_orjson.py b/api/tests/unit_tests/libs/test_orjson.pyindex 6df1d077df7..e5df20708cf 100644--- a/api/tests/unit_tests/libs/test_orjson.py+++ b/api/tests/unit_tests/libs/test_orjson.py@@ -4,13 +4,13 @@ import pytestfrom libs.orjson import orjson_dumps-def test_orjson_dumps_round_trip_basic():+def test_orjson_dumps_round_trip_basic() -> None:obj = {"a": 1, "b": [1, 2, 3], "c": {"d": True}}s = orjson_dumps(obj)assert orjson.loads(s) == obj-def test_orjson_dumps_with_unicode_and_indent():+def test_orjson_dumps_with_unicode_and_indent() -> None:obj = {"msg": "你好,Dify"}s = orjson_dumps(obj, option=orjson.OPT_INDENT_2)# contains indentation newline/spaces@@ -18,7 +18,7 @@ def test_orjson_dumps_with_unicode_and_indent():assert orjson.loads(s) == obj-def test_orjson_dumps_non_utf8_encoding_fails():+def test_orjson_dumps_non_utf8_encoding_fails() -> None:obj = {"msg": "你好"}# orjson.dumps() always produces UTF-8 bytes; decoding with non-UTF8 fails.with pytest.raises(UnicodeDecodeError):diff --git a/api/tests/unit_tests/pyrefly.toml b/api/tests/unit_tests/pyrefly.tomlindex f2af3fdc2b9..e662dc5b691 100644--- a/api/tests/unit_tests/pyrefly.toml+++ b/api/tests/unit_tests/pyrefly.toml@@ -171,7 +171,6 @@ project-excludes = ["core/app/apps/pipeline/test_pipeline_runner.py","core/app/apps/test_base_app_generator.py","core/app/apps/test_base_app_queue_manager.py",- "core/app/apps/test_exc.py","core/app/apps/test_message_based_app_generator.py","core/app/apps/test_message_generator.py","core/app/apps/test_streaming_utils.py",@@ -182,7 +181,6 @@ project-excludes = ["core/app/apps/workflow/test_app_config_manager.py","core/app/apps/workflow/test_app_queue_manager.py","core/app/apps/workflow/test_command_channels.py",- "core/app/apps/workflow/test_errors.py","core/app/apps/workflow/test_generate_response_converter.py","core/app/apps/workflow/test_generate_task_pipeline.py","core/app/entities/test_app_invoke_entities.py",@@ -195,7 +193,6 @@ project-excludes = ["core/app/layers/test_trigger_post_layer.py","core/app/task_pipeline/test_based_generate_task_pipeline.py","core/app/task_pipeline/test_easy_ui_based_generate_task_pipeline.py",- "core/app/task_pipeline/test_exc.py","core/app/task_pipeline/test_message_cycle_manager.py","core/app/app_config/easy_ui_based_app/model_config/test_manager.py","core/app/llm/test_quota.py",@@ -237,7 +234,6 @@ project-excludes = ["core/plugin/impl/test_asset.py","core/plugin/impl/test_base.py","core/plugin/impl/test_datasource.py",- "core/plugin/impl/test_debugging.py","core/plugin/impl/test_endpoint.py","core/plugin/impl/test_exc.py","core/plugin/impl/test_model.py",@@ -262,7 +258,6 @@ project-excludes = ["core/rag/extractor/test_excel_extractor.py","core/rag/extractor/test_extract_processor.py","core/rag/extractor/test_helpers.py",- "core/rag/extractor/test_html_extractor.py","core/rag/extractor/test_markdown_extractor.py","core/rag/extractor/test_word_extractor.py","core/rag/extractor/watercrawl/test_client.py",@@ -306,8 +301,6 @@ project-excludes = ["core/tools/workflow_as_tool/test_provider.py","core/tools/workflow_as_tool/test_tool.py","core/trigger/utils/test_encryption.py",- "core/trigger/utils/test_endpoint.py",- "core/trigger/utils/test_locks.py","context/test_execution_context.py","context/test_flask_app_context.py","../e2e_tests/contracts/core/workflow/entities/test_private_workflow_pause.py",@@ -398,7 +391,6 @@ project-excludes = ["libs/test_flask_utils.py","libs/test_helper.py","libs/test_login.py",- "libs/test_orjson.py","../e2e_tests/contracts/libs/test_pandas.py","libs/test_token.py","migrations/versions/test_2025_07_02_2332-1c9ba48be8e4_add_uuidv7_function_in_sql.py",@@ -480,7 +472,6 @@ project-excludes = ["services/tools/test_api_tools_manage_service.py","services/tools/test_builtin_tools_manage_service.py","services/tools/test_tools_transform_service.py",- "services/tools/test_tool_labels_service.py","services/tools/test_tools_manage_service.py","services/test_workflow_draft_variable_service.py","services/workflow/test_node_output_inspector_service.py",diff --git a/api/tests/unit_tests/services/tools/test_tool_labels_service.py b/api/tests/unit_tests/services/tools/test_tool_labels_service.pyindex 6acdbb79019..504169b22a5 100644--- a/api/tests/unit_tests/services/tools/test_tool_labels_service.py+++ b/api/tests/unit_tests/services/tools/test_tool_labels_service.py@@ -1,13 +1,13 @@from services.tools.tool_labels_service import ToolLabelsService-def test_list_tool_labels_returns_default_labels():+def test_list_tool_labels_returns_default_labels() -> None:result = ToolLabelsService.list_tool_labels()assert isinstance(result, list)assert len(result) > 0-def test_list_tool_labels_items_are_tool_labels():+def test_list_tool_labels_items_are_tool_labels() -> None:from core.tools.entities.tool_entities import ToolLabelresult = ToolLabelsService.list_tool_labels()@@ -15,7 +15,7 @@ def test_list_tool_labels_items_are_tool_labels():assert isinstance(label, ToolLabel)-def test_list_tool_labels_matches_default_values():+def test_list_tool_labels_matches_default_values() -> None:from core.tools.entities.values import default_tool_labelsassert ToolLabelsService.list_tool_labels() is default_tool_labels