Repository navigation
Conversation
Graduate `test_streaming_utils`, `test_plugin_daemon`, the service-api package `__init__` and `test_dataset_multi_retriever_tool` out of the `project-excludes` list by dropping the type suppressions they relied on. The fakes now extend the real classes they stand in for, `current_app` is patched with the real `LocalProxy` instead of a hand-written stand-in, and the assertions that inspected untyped mappings go through small narrowing helpers. One assertion that only reached the unreachable `else` branch of `CredentialType.get_name` was dropped together with the fabricated enum value it needed: every caller passes a declared member, so the branch cannot be observed from a real object.
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-11-28 04:04:57.969318224 +0000
+++ /tmp/pyrefly_pr.txt 2026-11-28 04:04:47.293279938 +0000
@@ -3254,50 +3254,6 @@
--> tests/unit_tests/core/app/apps/test_base_app_runner.py:821:17
ERROR Argument `TestAppRunner.test_handle_multimodal_image_content_fallback_return_branch._ToggleBool` is not assignable to parameter `base64_data` with type `str` in function `graphon.model_runtime.entities.message_entities.ImagePromptMessageContent.model_construct` [bad-argument-type]
--> tests/unit_tests/core/app/apps/test_base_app_runner.py:822:25
-ERROR Class member `FakePreparedSubscriber.prepare_subscription` overrides parent class `SupportsPreparedSubscription` in an inconsistent manner [bad-override]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:125:9
-ERROR Class member `FakePreparedSubscriber.subscribe` overrides parent class `SupportsPreparedSubscription` in an inconsistent manner [bad-override]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:129:9
-ERROR Class member `FailingPreparedSubscriber.prepare_subscription` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:134:9
-ERROR Class member `FakePreparedTopic.as_subscriber` overrides parent class `FakeTopic` in an inconsistent manner [bad-override]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:143:9
-ERROR Class member `FakePreparedTopic.as_subscriber` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:143:9
-ERROR Class member `FailingPreparedTopic.as_subscriber` overrides parent class `FakeTopic` in an inconsistent manner [bad-override]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:153:9
-ERROR Class member `FailingPreparedTopic.as_subscriber` overrides a member in a parent class but is missing an `@override` decorator [missing-override-decorator]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:153:9
-ERROR Cannot index into `str` [bad-index]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:183:12
-ERROR Cannot index into `str` [bad-index]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:209:12
-ERROR Argument `FakeSubscription` is not assignable to parameter `subscription` with type `Subscription` in function `core.app.apps.streaming_utils.stream_topic_events` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:250:22
-ERROR Argument `FakeSubscription` is not assignable to parameter `subscription` with type `Subscription` in function `core.app.apps.streaming_utils.stream_topic_events` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:267:22
-ERROR Cannot index into `str` [bad-index]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:273:12
-ERROR Cannot index into `str` [bad-index]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:274:12
-ERROR Argument `FakeSubscription` is not assignable to parameter `subscription` with type `Subscription` in function `core.app.apps.streaming_utils.stream_topic_events` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:289:52
-ERROR Argument `FakeSubscription` is not assignable to parameter `subscription` with type `Subscription` in function `core.app.apps.streaming_utils.stream_topic_events` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:305:26
-ERROR Argument `FakeSubscription` is not assignable to parameter `subscription` with type `Subscription` in function `core.app.apps.streaming_utils.stream_topic_events` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:360:56
-ERROR Argument `Literal['session']` is not assignable to parameter `type` with type `EndUserType | SQLCoreOperations[EndUserType]` in function `models.model.EndUser.__init__` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:383:48
-ERROR Argument `Literal[core.app.entities.app_invoke_entities.InvokeFrom.WEB_APP]` is not assignable to parameter `invoke_from` with type `models.enums.InvokeFrom | SQLCoreOperations[models.enums.InvokeFrom | None] | None` in function `models.model.Message.__init__` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:393:21
-ERROR Argument `str | None` is not assignable to parameter `workflow_run_id` with type `UUID | str` in function `tasks.app_generate.workflow_execute_task._publish_streaming_response` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:452:9
-ERROR Argument `FakeSubscription` is not assignable to parameter `subscription` with type `Subscription` in function `core.app.apps.streaming_utils.stream_topic_events` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:461:52
-ERROR Argument `Literal[graphon.enums.WorkflowType.CHAT]` is not assignable to parameter `workflow_type` with type `models.workflow.WorkflowType` in function `tests.helpers.unit.model_factories.make_workflow` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:518:23
-ERROR Argument `Literal['session']` is not assignable to parameter `type` with type `EndUserType | SQLCoreOperations[EndUserType]` in function `models.model.EndUser.__init__` [bad-argument-type]
- --> tests/unit_tests/core/app/apps/test_streaming_utils.py:533:67
ERROR Argument `Mapping[str, Any] | None` is not assignable to parameter `graph_config` with type `Mapping[str, Any]` in function `core.workflow.workflow_entry.WorkflowEntry.__init__` [bad-argument-type]
--> tests/unit_tests/core/app/apps/test_workflow_app_runner.py:145:39
ERROR No matching overload found for function `dict.get` called with arguments: (dict[str, int | list[Unknown] | str] | dict[str, list[str] | str] | dict[str, list[Unknown] | str] | dict[str, str] | str, Literal['']) [no-matching-overload]
|
Pyrefly Type Coverage
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #46457 +/- ##
=======================================
Coverage 90.62% 90.62%
=======================================
Files 6665 6665
Lines 415303 415329 +26
Branches 83292 83291 -1
=======================================
+ Hits 376363 376391 +28
+ Misses 32556 32553 -3
- Partials 6384 6385 +1
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:
|
| } | ||
|
|
||
|
|
||
| def _mapping(value: object) -> dict[str, object]: |
Replace the four module-level helpers (_mapping, _listing, _path, _branches) with explicit intermediates plus assert isinstance(...) at each call site, matching the 21 assertions the module already used. The helpers only existed because json.loads returns Any; nothing in the production code was widened, so there is no origin annotation to tighten. dict[str, Any] is not an option either: the unit-test lint config bans typing.Any, which points callers at object plus narrowing.
|
Typed the payloads at each call site, and dropped the helpers.
components = payload["components"]
assert isinstance(components, dict)
schemas = components["schemas"]
assert isinstance(schemas, dict)
resolved = schemas[schema_name]The helpers only existed to hide Assertions are unchanged — 42 tests still pass, pyrefly reports the same 29 pre-existing missing-import lines and nothing else. |
| schema_name = ref.removeprefix("#/components/schemas/") | ||
| resolved = payload["components"]["schemas"][schema_name] | ||
| components = payload["components"] | ||
| assert isinstance(components, dict) |
There was a problem hiding this comment.
typeddict , put into origin code if possible.
There was a problem hiding this comment.
5 inline suggestions at c4894df02c, each from a rule learned from earlier reviews in this repository. Reply on a comment if it is wrong.
dify-codereview
There was a problem hiding this comment.
4 inline suggestions at c4894df02c, each from a rule learned from earlier reviews in this repository. Reply on a comment if it is wrong.
dify-codereview
The service API contract tests unloaded the rendered OpenAPI JSON into dict[str, object] and re-checked every key and value type where they were used, which is validation spread across the test bodies. This change moves the document shape into libs/openapi_document.py: the raw payload is parsed once at the boundary, and the tests then read paths, schemas, operations, parameters, properties, required fields and anyOf variants through typed accessors. It also follows the review on the other two files: the parametrized cases in test_plugin_daemon.py now declare the union of the case types instead of object, the file-system retriever helper spells out its keyword parameters, and the case that only re-checked a type error the type checker already rejects is gone.
|
All four For For For the Verification: pyrefly strict mode on |
asukaminato0721
left a comment
There was a problem hiding this comment.
4 inline suggestions at cb183fc35f, each from a rule learned from earlier reviews in this repository. Reply on a comment if it is wrong.
dify-codereview
The typed accessors that replaced the per-test peeling were only exercised indirectly, so the changed-line coverage gate failed on them. Cover the parsing boundary and each accessor, including the paths that reject a document whose shape the format does not allow.
asukaminato0721
left a comment
There was a problem hiding this comment.
4 inline suggestions at a989843509, each from a rule learned from earlier reviews in this repository. Reply on a comment if it is wrong. 4 earlier suggestions are still open.
dify-codereview
…-api Both sides only moved lines in the pyrefly exclude list: this branch graduates its own test files while upstream graduates different ones. Keep both removals and upstream's new entry.
asukaminato0721
left a comment
There was a problem hiding this comment.
1 inline suggestion at 9bc36dfbd4, from a rule learned from earlier reviews in this repository. Reply on the comment if it is wrong. 10 review threads are still unresolved.
dify-codereview
Address the review notes on PR langgenius#46457 without suppressing types: - openapi_document: validate document lookups through pydantic parsing instead of isinstance-then-assume paths, and expose precise return shapes so callers no longer re-check or cast - streaming_utils / message_generator / task_entities / parameters: replace the loose dict[str, object] views with the real payload types - tests assert returned and raised behaviour via real collaborators instead of pinned calls
asukaminato0721
left a comment
There was a problem hiding this comment.
1 inline suggestion at 22fcc125a3, from a rule learned from earlier reviews in this repository. Reply on the comment if it is wrong. 2 review threads are still unresolved.
dify-codereview
Preserve both branches’ Pyrefly exclusion removals and remove the synchronous test-only Thread stand-in.
asukaminato0721
left a comment
There was a problem hiding this comment.
1 inline suggestion at 67f13df7ec, from a rule learned from earlier reviews in this repository. Reply on the comment if it is wrong. 2 review threads are still unresolved.
dify-codereview
|
Follow-up to the conflict review: merged current |
|
Thanks for the scope review. |
|
Could a maintainer rerun just the API Integration Tests job for |
asukaminato0721
left a comment
There was a problem hiding this comment.
CI is failing: API Tests, Run API Tests / API Integration Tests (3.13). Please fix it. Checked 4a711afd9e. 2 review threads are still unresolved.
dify-codereview
Small enough to review: the split request no longer applies.
Summary
Enable strict Pyrefly checking for
test_streaming_utils.py. Type the streaming event iterators and test subscription doubles together so the existing stream retrieval and subscription coverage can run under the strict configuration.This PR is now limited to streaming utilities. The plugin, service API/OpenAPI, and dataset retriever changes are not in the current diff.
Verification
pytestontest_streaming_utils.pyandtest_base_app_generator.py: 63 passed.