Skip to content

chore: add type to test#36324

Merged
asukaminato0721 merged 14 commits into
langgenius:mainfrom
asukaminato0721:type-test
May 18, 2026
Merged

chore: add type to test#36324
asukaminato0721 merged 14 commits into
langgenius:mainfrom
asukaminato0721:type-test

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

#35871

Screenshots

Before After
... ...

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Copilot AI review requested due to automatic review settings May 18, 2026 07:34
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 18, 2026
@asukaminato0721 asukaminato0721 enabled auto-merge May 18, 2026 07:34
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-05-18 08:22:46.608488381 +0000
+++ /tmp/pyrefly_pr.txt	2026-05-18 08:22:37.665505841 +0000
@@ -773,17 +773,15 @@
 ERROR Generator function should return `Generator` [bad-return]
   --> tests/test_containers_integration_tests/repositories/test_workflow_run_repository.py:89:56
 ERROR `None` is not subscriptable [unsupported-operation]
-   --> tests/test_containers_integration_tests/services/auth/test_api_key_auth_service.py:190:16
-ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
-  --> tests/test_containers_integration_tests/services/dataset_service_update_delete.py:41:20
-ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
-  --> tests/test_containers_integration_tests/services/dataset_service_update_delete.py:47:62
+   --> tests/test_containers_integration_tests/services/auth/test_api_key_auth_service.py:191:16
+ERROR Could not find name `Session` [unknown-name]
+  --> tests/test_containers_integration_tests/services/plugin/test_plugin_parameter_service.py:54:37
+ERROR Could not find name `Session` [unknown-name]
+  --> tests/test_containers_integration_tests/services/plugin/test_plugin_parameter_service.py:96:37
 ERROR Object of class `NoneType` has no attribute `version` [missing-attribute]
-  --> tests/test_containers_integration_tests/services/plugin/test_plugin_service.py:50:16
+  --> tests/test_containers_integration_tests/services/plugin/test_plugin_service.py:53:16
 ERROR Object of class `NoneType` has no attribute `version` [missing-attribute]
-  --> tests/test_containers_integration_tests/services/plugin/test_plugin_service.py:68:16
-ERROR Argument `Literal['custom']` is not assignable to parameter `preferred_provider_type` with type `ProviderType | SQLCoreOperations[ProviderType]` in function `models.provider.TenantPreferredModelProvider.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/plugin/test_plugin_service.py:377:37
+  --> tests/test_containers_integration_tests/services/plugin/test_plugin_service.py:71:16
 ERROR Object of class `NoneType` has no attribute `open_id` [missing-attribute]
    --> tests/test_containers_integration_tests/services/test_account_service.py:530:16
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
@@ -814,10 +812,6 @@
    --> tests/test_containers_integration_tests/services/test_advanced_prompt_template_service.py:894:63
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/test_containers_integration_tests/services/test_agent_service.py:134:38
-ERROR `str` is not assignable to attribute `agent_mode` with type `Never` [bad-assignment]
-   --> tests/test_containers_integration_tests/services/test_agent_service.py:138:47
-ERROR Argument `Literal['account']` is not assignable to parameter `created_by_role` with type `CreatorUserRole | SQLCoreOperations[CreatorUserRole]` in function `models.model.MessageAgentThought.__init__` [bad-argument-type]
-   --> tests/test_containers_integration_tests/services/test_agent_service.py:275:29
 ERROR Argument `str | None` is not assignable to parameter `created_by` with type `SQLCoreOperations[str] | str` in function `models.model.MessageAgentThought.__init__` [bad-argument-type]
    --> tests/test_containers_integration_tests/services/test_agent_service.py:565:24
 ERROR Argument `str | None` is not assignable to parameter `created_by` with type `SQLCoreOperations[str] | str` in function `models.model.MessageAgentThought.__init__` [bad-argument-type]
@@ -857,7 +851,7 @@
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/test_containers_integration_tests/services/test_api_based_extension_service.py:527:57
 ERROR Argument `Literal['app']` is not assignable to parameter `value` with type `ApiTokenType | SQLCoreOperations[ApiTokenType]` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
-  --> tests/test_containers_integration_tests/services/test_api_token_service.py:27:26
+  --> tests/test_containers_integration_tests/services/test_api_token_service.py:28:26
 ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
    --> tests/test_containers_integration_tests/services/test_app_dsl_service.py:161:42
 ERROR Argument `Literal['simple']` is not assignable to parameter `prompt_type` with type `PromptType | SQLCoreOperations[PromptType]` in function `models.model.AppModelConfig.__init__` [bad-argument-type]
@@ -1025,7 +1019,7 @@
 ERROR Argument `Literal['owner']` is not assignable to parameter `role` with type `SQLCoreOperations[TenantAccountRole] | TenantAccountRole` in function `models.account.TenantAccountJoin.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/test_human_input_delivery_test.py:32:18
 ERROR Unexpected keyword argument `whole_workspace` in function `core.workflow.human_input_adapter.EmailRecipients.__init__` [unexpected-keyword]
-   --> tests/test_containers_integration_tests/services/test_human_input_delivery_test_service.py:240:44
+   --> tests/test_containers_integration_tests/services/test_human_input_delivery_test_service.py:241:44
 ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
   --> tests/test_containers_integration_tests/services/test_message_export_service.py:53:20
 ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
@@ -2009,27 +2003,27 @@
 ERROR Argument `SimpleNamespace` is not assignable to parameter `application_generate_entity` with type `AdvancedChatAppGenerateEntity | WorkflowAppGenerateEntity` in function `core.app.apps.common.workflow_response_converter.WorkflowResponseConverter.__init__` [bad-argument-type]
   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:98:37
 ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `WorkflowSnapshot` in function `core.app.apps.advanced_chat.generate_task_pipeline.AdvancedChatAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:425:22
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:427:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.advanced_chat.generate_task_pipeline.AdvancedChatAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:426:27
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:428:27
 ERROR Argument `SimpleNamespace` is not assignable to parameter `conversation` with type `ConversationSnapshot` in function `core.app.apps.advanced_chat.generate_task_pipeline.AdvancedChatAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:427:26
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:429:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `message` with type `MessageSnapshot` in function `core.app.apps.advanced_chat.generate_task_pipeline.AdvancedChatAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:428:21
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:430:21
 ERROR Argument `(**kwargs: Unknown) -> None` is not assignable to parameter `draft_var_saver_factory` with type `DraftVariableSaverFactory` in function `core.app.apps.advanced_chat.generate_task_pipeline.AdvancedChatAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:438:37
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:440:37
 ERROR Argument `SimpleNamespace` is not assignable to parameter `workflow` with type `Workflow` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:518:22
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:520:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `queue_manager` with type `AppQueueManager` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:519:27
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:521:27
 ERROR Argument `SimpleNamespace` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:520:18
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:522:18
 ERROR Argument `(**kwargs: Unknown) -> None` is not assignable to parameter `draft_var_saver_factory` with type `DraftVariableSaverFactory` in function `core.app.apps.workflow.generate_task_pipeline.WorkflowAppGenerateTaskPipeline.__init__` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:522:37
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:524:37
 ERROR Argument `SimpleNamespace` is not assignable to parameter `graph_runtime_state` with type `GraphRuntimeState` in function `core.app.apps.common.workflow_response_converter.WorkflowResponseConverter.workflow_pause_to_stream_response` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:612:33
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:614:33
 ERROR Argument `() -> TestHitlServiceApi.test_snapshot_events_include_pause_payload_contract._SessionContext` is not assignable to parameter `session_maker` with type `sessionmaker[Session] | None` in function `services.workflow_event_snapshot_service._build_snapshot_events` [bad-argument-type]
-   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:685:27
+   --> tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py:687:27
 ERROR Argument value `Literal[0]` violates Pydantic `ge` constraint `Literal[1]` for field `limit` [bad-argument-type]
   --> tests/unit_tests/controllers/service_api/app/test_message.py:95:63
 ERROR Argument value `Literal[101]` violates Pydantic `le` constraint `Literal[100]` for field `limit` [bad-argument-type]
@@ -2091,9 +2085,9 @@
 ERROR Argument `list[str] | None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
    --> tests/unit_tests/controllers/service_api/dataset/test_dataset_segment.py:597:20
 ERROR Object of class `NoneType` has no attribute `name` [missing-attribute]
-   --> tests/unit_tests/controllers/service_api/dataset/test_document.py:237:16
-ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
    --> tests/unit_tests/controllers/service_api/dataset/test_document.py:238:16
+ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
+   --> tests/unit_tests/controllers/service_api/dataset/test_document.py:239:16
 ERROR Missing argument `app_model` in function `protected_view` [missing-argument]
    --> tests/unit_tests/controllers/service_api/test_wraps.py:156:36
 ERROR `object` is not assignable to attribute `request` with type `Request` [bad-assignment]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 18, 2026

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 0.00% 44.42% +44.42%
Strict coverage 0.00% 43.94% +43.94%
Typed symbols 0 22,512 +22,512
Untyped symbols 0 28,473 +28,473
Modules 0 2558 +2,558

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds missing type annotations across test suites (unit + container integration) to improve static type-checking consistency, with a few incidental value/type updates in test fixtures.

Changes:

  • Annotate common pytest fixtures/params (e.g., app, flask_app_with_containers, db sessions) with concrete types like Flask/Session.
  • Add necessary imports to support the new annotations in many test modules.
  • Normalize some test data to use enum values instead of raw strings in a few places.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
api/tests/unit_tests/controllers/service_api/test_index.py Add Flask type annotation to app fixture usage in parametrized test
api/tests/unit_tests/controllers/service_api/app/test_workflow_events.py Add Flask type annotation to app fixture usage
api/tests/unit_tests/controllers/service_api/app/test_message.py Add Flask type annotations to app fixture usage
api/tests/unit_tests/controllers/service_api/app/test_human_input_form.py Import Flask and annotate app fixture usage
api/tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py Add Flask annotation and reflow long test signature
api/tests/unit_tests/controllers/service_api/app/test_file_preview.py Add FilePreviewApi type annotations for fixture clarity
api/tests/unit_tests/controllers/service_api/app/test_conversation.py Add Flask type annotations to app fixture usage
api/tests/unit_tests/controllers/service_api/app/test_completion.py Add Flask type annotations; adjust one AppMode usage
api/tests/unit_tests/controllers/service_api/app/test_annotation.py Import Flask and annotate app fixture usage
api/tests/unit_tests/controllers/console/workspace/test_plugin.py Add Flask type annotation to app fixture usage
api/tests/unit_tests/controllers/console/workspace/test_accounts.py Add Flask type annotation to app fixture usage
api/tests/unit_tests/controllers/console/test_files.py Add Flask type annotations to app fixture usage across file controller tests
api/tests/unit_tests/controllers/console/tag/test_tags.py Add Flask type annotations to app fixture usage
api/tests/unit_tests/controllers/console/explore/test_workflow.py Add Flask type annotations to app fixture usage
api/tests/unit_tests/controllers/console/explore/test_trial.py Add Flask type annotations to app fixture usage across trial APIs
api/tests/unit_tests/controllers/console/explore/test_saved_message.py Add Flask type annotations to app fixture usage
api/tests/unit_tests/controllers/console/explore/test_installed_app.py Import Flask and annotate app fixture usage
api/tests/unit_tests/controllers/console/explore/test_completion.py Import Flask and annotate app fixture usage
api/tests/unit_tests/controllers/console/explore/test_audio.py Import Flask and annotate app fixture usage
api/tests/unit_tests/controllers/console/datasets/test_website.py Add Flask type annotations to dataset website crawl tests
api/tests/unit_tests/controllers/console/datasets/test_metadata.py Add Flask type annotations to dataset metadata controller tests
api/tests/unit_tests/controllers/console/datasets/test_external.py Add Flask type annotations to external dataset controller tests
api/tests/unit_tests/controllers/console/datasets/test_datasets_document.py Add Flask type annotations and reflow long test signatures
api/tests/unit_tests/controllers/console/datasets/rag_pipeline/test_rag_pipeline_draft_variable.py Import Flask and annotate app fixture usage
api/tests/test_containers_integration_tests/services/test_metadata_partial_update.py Import Flask; add Session annotations to helpers and test params
api/tests/test_containers_integration_tests/services/test_human_input_delivery_test_service.py Import Flask and annotate container app fixture usage
api/tests/test_containers_integration_tests/services/test_file_service_zip_and_lookup.py Import Session and annotate db session parameters
api/tests/test_containers_integration_tests/services/test_api_token_service.py Import Flask and annotate container app fixture usage
api/tests/test_containers_integration_tests/services/test_agent_service.py Switch one mode check + created-by role to enum constants
api/tests/test_containers_integration_tests/services/recommend_app/test_database_retrieval.py Import Flask; add Session annotations to helper builders and tests
api/tests/test_containers_integration_tests/services/plugin/test_plugin_service.py Import Flask/Session; use ProviderType enum in test data
api/tests/test_containers_integration_tests/services/plugin/test_plugin_parameter_service.py Import Flask; add Flask/Session annotations to fixtures
api/tests/test_containers_integration_tests/services/enterprise/test_account_deletion_sync.py Import Flask and annotate container app fixture usage
api/tests/test_containers_integration_tests/services/dataset_service_update_delete.py Use enum constants for Account/Tenant status values in tests
api/tests/test_containers_integration_tests/services/auth/test_auth_integration.py Import Flask; add Flask/Session annotations to integration tests
api/tests/test_containers_integration_tests/services/auth/test_api_key_auth_service.py Import Flask; add Flask annotations to container app fixture usage
api/tests/test_containers_integration_tests/controllers/console/workspace/test_trigger_providers.py Add Flask type annotation to app fixture usage
api/tests/test_containers_integration_tests/controllers/console/test_apikey.py Import Flask and annotate container app fixture usage
Comments suppressed due to low confidence (1)

api/tests/unit_tests/controllers/service_api/app/test_completion.py:1

  • app_model.mode is set to AppMode.COMPLETION here, but other tests in this file commonly use AppMode.<...>.value when a string mode is expected. If the controller’s mode checks compare against string values, this will make the test exercise a different path (or fail). Use the same representation used elsewhere in the file (e.g., AppMode.COMPLETION.value), or consistently use the enum everywhere based on what the production code expects.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

WH-2099
WH-2099 previously approved these changes May 18, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 18, 2026
@autofix-ci autofix-ci Bot requested review from Yeuoly and crazywoola as code owners May 18, 2026 08:01
@github-actions github-actions Bot added the web This relates to changes on the web. label May 18, 2026
WH-2099
WH-2099 previously approved these changes May 18, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue May 18, 2026
Merged via the queue into langgenius:main with commit 76bba64 May 18, 2026
32 checks passed
@asukaminato0721 asukaminato0721 deleted the type-test branch May 18, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files. web This relates to changes on the web.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants