chore: add type to test#36324
Merged
Merged
Conversation
Contributor
Pyrefly Diffbase → 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]
|
Contributor
Pyrefly Type Coverage
|
Contributor
There was a problem hiding this comment.
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 likeFlask/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.modeis set toAppMode.COMPLETIONhere, but other tests in this file commonly useAppMode.<...>.valuewhen 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
previously approved these changes
May 18, 2026
WH-2099
previously approved these changes
May 18, 2026
WH-2099
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Fixes #<issue number>.Summary
#35871
Screenshots
Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint gods