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
test(api): bring the workflow model tests under strict pyrefly (#45629)
yetuge4f47f7212216
diff --git a/api/tests/unit_tests/models/test_workflow.py b/api/tests/unit_tests/models/test_workflow.pyindex b3c2af1396b..32195d9fc03 100644--- a/api/tests/unit_tests/models/test_workflow.py+++ b/api/tests/unit_tests/models/test_workflow.py@@ -103,7 +103,7 @@ class TestConversationVariableCases:class TestWorkflowCases:@staticmethod- def test_environment_variables():+ def test_environment_variables() -> None:# tenant_id context variable removed - using current_user.current_tenant_id directly# Create a Workflow instance@@ -137,7 +137,7 @@ class TestWorkflowCases:assert workflow.environment_variables == variables@staticmethod- def test_llm_environment_variable_round_trip():+ def test_llm_environment_variable_round_trip() -> None:workflow = _workflow_Workflow(tenant_id="tenant_id",app_id="app_id",@@ -163,7 +163,7 @@ class TestWorkflowCases:assert workflow.to_dict()["environment_variables"][0]["value_type"] == "llm"@staticmethod- def test_update_environment_variables():+ def test_update_environment_variables() -> None:# tenant_id context variable removed - using current_user.current_tenant_id directly# Create a Workflow instance@@ -216,7 +216,7 @@ class TestWorkflowCases:assert workflow.environment_variables[2].value == variable3.value@staticmethod- def test_to_dict():+ def test_to_dict() -> None:# tenant_id context variable removed - using current_user.current_tenant_id directly# Create a Workflow instance@@ -254,7 +254,7 @@ class TestWorkflowCases:@staticmethod@pytest.mark.parametrize("sqlite_session", [(_workflow_Workflow, Account)], indirect=True)- def test_workflow_account_accessors_use_caller_session(sqlite_session: Session):+ def test_workflow_account_accessors_use_caller_session(sqlite_session: Session) -> None:created_account = Account(name="Created Account", email="[email protected]")created_account.id = "created-account-id"updated_account = Account(name="Updated Account", email="[email protected]")@@ -281,7 +281,7 @@ class TestWorkflowCases:@staticmethod@pytest.mark.parametrize("sqlite_session", [(_workflow_Workflow, WorkflowToolProvider)], indirect=True)- def test_workflow_tool_published_accessor_uses_caller_session(sqlite_session: Session):+ def test_workflow_tool_published_accessor_uses_caller_session(sqlite_session: Session) -> None:workflow = _workflow_Workflow(tenant_id="tenant_id",app_id="app_id",@@ -317,10 +317,11 @@ class TestWorkflowCases:sqlite_session.flush()with pytest.warns(DeprecationWarning, match="not accurate"):- assert workflow.tool_published(sqlite_session) is True+ # The deprecated accessor is the compatibility surface under test.+ assert workflow.tool_published(sqlite_session) is True # pyrefly: ignore[deprecated]@staticmethod- def test_normalize_environment_variable_mappings_converts_full_mask_to_hidden_value():+ def test_normalize_environment_variable_mappings_converts_full_mask_to_hidden_value() -> None:normalized = _workflow_Workflow.normalize_environment_variable_mappings([{@@ -335,7 +336,7 @@ class TestWorkflowCases:assert normalized[0]["value"] == HIDDEN_VALUE@staticmethod- def test_normalize_environment_variable_mappings_keeps_hidden_value():+ def test_normalize_environment_variable_mappings_keeps_hidden_value() -> None:normalized = _workflow_Workflow.normalize_environment_variable_mappings([{@@ -350,7 +351,7 @@ class TestWorkflowCases:assert normalized[0]["value"] == HIDDEN_VALUEclass TestWorkflowNodeExecution:- def test_execution_metadata_dict(self):+ def test_execution_metadata_dict(self) -> None:node_exec = WorkflowNodeExecutionModel(execution_metadata=None,)@@ -361,7 +362,7 @@ class TestWorkflowCases:assert node_exec.execution_metadata_dict == originalclass TestIsSystemVariableEditable:- def test_is_system_variable(self):+ def test_is_system_variable(self) -> None:cases = [("query", True),("files", True),@@ -378,7 +379,7 @@ class TestWorkflowCases:assert is_system_variable_editable("invalid_or_new_system_variable") is Falseclass TestWorkflowDraftVariableGetValue:- def test_get_value_by_case(self):+ def test_get_value_by_case(self) -> None:@dataclasses.dataclassclass TestCase:name: str@@ -450,7 +451,7 @@ class TestWorkflowCases:draft_var.set_value(c.value)assert c.value == draft_var.get_value(), fail_msg- def test_file_variable_preserves_all_fields(self):+ def test_file_variable_preserves_all_fields(self) -> None:"""Test that File type variables preserve all fields during encoding/decoding."""# Create a File with specific field values@@ -489,7 +490,7 @@ class TestWorkflowCases:# Verify the segments have the same type and the important fields matchassert file_segment.value_type == retrieved_segment.value_type- def test_file_variable_rebuilds_storage_backed_payloads_with_app_tenant(self):+ def test_file_variable_rebuilds_storage_backed_payloads_with_app_tenant(self) -> None:persisted_file = File(file_id="test_file_id",file_type=FileType.DOCUMENT,@@ -515,7 +516,7 @@ class TestWorkflowCases:app_id="app-1",)draft_var.set_value(build_segment(persisted_file))- draft_var._WorkflowDraftVariable__value = None+ draft_var._WorkflowDraftVariable__value = None # pyrefly: ignore[missing-attribute]with (mock.patch("models.workflow._resolve_workflow_app_tenant_id", return_value="tenant-1"),@@ -527,7 +528,7 @@ class TestWorkflowCases:rebuild_file.assert_called_once()assert rebuild_file.call_args.kwargs["tenant_id"] == "tenant-1"- def test_get_and_set_value(self):+ def test_get_and_set_value(self) -> None:draft_var = WorkflowDraftVariable()int_var = IntegerSegment(value=1)draft_var.set_value(int_var)@@ -656,7 +657,7 @@ class TestWorkflowFeatureCompatibilityCases:workflow = _workflow_feature_compatibility_Workflow(tenant_id="",app_id="",- type="",+ type=WorkflowType.WORKFLOW,version="",graph="",_features=json.dumps(OLD_VERSION_WORKFLOW_FEATURES),@@ -1171,7 +1172,7 @@ class TestWorkflowModelsCases:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.SINGLE_STEP.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.SINGLE_STEP,workflow_run_id=None, # Single-step has no workflow runindex=1,node_id="llm_test",@@ -2007,7 +2008,7 @@ def _run(role: CreatorUserRole, created_by: str) -> WorkflowRun:type=ModelWorkflowType.WORKFLOW,triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="1.0",- status="succeeded",+ status=WorkflowExecutionStatus.SUCCEEDED,created_by_role=role,created_by=created_by,)diff --git a/api/tests/unit_tests/pyrefly.toml b/api/tests/unit_tests/pyrefly.tomlindex 4220ca93946..35b743d4df3 100644--- a/api/tests/unit_tests/pyrefly.toml+++ b/api/tests/unit_tests/pyrefly.toml@@ -270,7 +270,6 @@ project-excludes = ["models/test_model.py","models/test_dataset.py","models/test_tools.py",- "models/test_workflow.py","services/agent/test_dsl_service.py","services/agent/test_roster_service.py","../helpers/unit/services/controller_api.py",