Repository navigation
test(api): strictly type service API fixtures and conversation tests - #45180
asukaminato0721 merged 2 commits into
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-10-31 16:20:56.393118790 +0000
+++ /tmp/pyrefly_pr.txt 2026-10-31 16:20:37.152914162 +0000
@@ -2556,10 +2556,6 @@
--> tests/unit_tests/controllers/service_api/app/test_audio.py:205:16
ERROR Argument `list[dict[str, Any]] | None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
--> tests/unit_tests/controllers/service_api/app/test_completion.py:258:24
-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_conversation.py:69:39
-ERROR Argument value `Literal[101]` violates Pydantic `le` constraint `Literal[100]` for field `limit` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/app/test_conversation.py:74:39
ERROR Class member `_FakePauseEntity.get_pause_reasons` is marked as an override, but no parent class has a matching attribute [bad-override]
--> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:274:9
ERROR Argument `Literal['app-run']` is not assignable to parameter `triggered_from` with type `SQLCoreOperations[WorkflowRunTriggeredFrom] | WorkflowRunTriggeredFrom` in function `models.workflow.WorkflowRun.__init__` [bad-argument-type]
@@ -2576,28 +2572,6 @@
--> tests/unit_tests/controllers/service_api/app/test_workflow_events.py:627:37
ERROR Argument `SimpleNamespace` is not assignable to parameter `graph_runtime_state` with type `RuntimeState` 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_workflow_events.py:717:33
-ERROR Argument `list[FromClause]` is not assignable to parameter `tables` with type `Sequence[Table] | None` in function `sqlalchemy.sql.schema.MetaData.create_all` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/conftest.py:39:16
-ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `AppStatus | SQLCoreOperations[AppStatus]` in function `models.model.App.__init__` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/conftest.py:106:16
-ERROR Argument `Literal['app']` is not assignable to parameter `type` with type `ApiTokenType | SQLCoreOperations[ApiTokenType]` in function `models.model.ApiToken.__init__` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/conftest.py:135:14
-ERROR Argument `Literal['dataset']` is not assignable to parameter `type` with type `ApiTokenType | SQLCoreOperations[ApiTokenType]` in function `models.model.ApiToken.__init__` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/conftest.py:145:14
-ERROR Missing argument `position` in function `models.dataset.Document.__init__` [missing-argument]
- --> tests/unit_tests/controllers/service_api/conftest.py:170:24
-ERROR Missing argument `data_source_type` in function `models.dataset.Document.__init__` [missing-argument]
- --> tests/unit_tests/controllers/service_api/conftest.py:170:24
-ERROR Missing argument `batch` in function `models.dataset.Document.__init__` [missing-argument]
- --> tests/unit_tests/controllers/service_api/conftest.py:170:24
-ERROR Missing argument `created_from` in function `models.dataset.Document.__init__` [missing-argument]
- --> tests/unit_tests/controllers/service_api/conftest.py:170:24
-ERROR Missing argument `created_by` in function `models.dataset.Document.__init__` [missing-argument]
- --> tests/unit_tests/controllers/service_api/conftest.py:170:24
-ERROR Argument `Literal['completed']` is not assignable to parameter `indexing_status` with type `IndexingStatus | SQLCoreOperations[IndexingStatus]` in function `models.dataset.Document.__init__` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/conftest.py:175:25
-ERROR Argument `Literal['completed']` is not assignable to parameter `status` with type `SQLCoreOperations[SegmentStatus] | SegmentStatus` in function `models.dataset.DocumentSegment.__init__` [bad-argument-type]
- --> tests/unit_tests/controllers/service_api/conftest.py:197:16
ERROR Argument `None` is not assignable to parameter `value` with type `SQLCoreOperations[datetime] | datetime` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
--> tests/unit_tests/controllers/service_api/dataset/rag_pipeline/test_rag_pipeline_workflow.py:868:34
ERROR No matching overload found for function `typing.MutableMapping.update` called with arguments: (dict[str, object]) [no-matching-overload]
|
Pyrefly Type Coverage
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #45180 +/- ##
==========================================
+ Coverage 89.84% 89.85% +0.01%
==========================================
Files 6244 6249 +5
Lines 397460 398118 +658
Branches 80168 80224 +56
==========================================
+ Hits 357079 357720 +641
- Misses 34080 34087 +7
- Partials 6301 6311 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Refs #24645.
Service API fixtures and conversation tests are excluded from strict Pyrefly checking. Annotate their parameters and returns, use the models' enum fields and required constructor arguments, and remove both exclusions so CI checks them.
The response test uses the real SegmentType enum instead of SimpleNamespace. Following review, remove the two limit-rejection cases. The valid limit boundaries and all remaining test bodies and assertions are preserved.
Evidence
Merge Danger
Reversible; scope is tests and strict-check configuration. Given valid fixture inputs, factories return real models with the required fields. Production behavior, including pagination constraints, is unchanged.
Screenshots
Not applicable.
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint gods — equivalent backend commands were run individually on Windows; no frontend changes.