refactor(api): type hit testing retrieve responses with TypedDict#34484
Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom Apr 3, 2026
Merged
Conversation
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-02 15:29:44.146895213 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-02 15:29:34.642832058 +0000
@@ -6267,24 +6267,42 @@
--> tests/unit_tests/services/external_dataset_service.py:849:36
ERROR Cannot index into `list[Unknown]` [bad-index]
--> tests/unit_tests/services/hit_service.py:430:20
+ERROR Cannot index into `object` [bad-index]
+ --> tests/unit_tests/services/hit_service.py:430:20
+ERROR Argument `dict[str, str] | list[Unknown] | object` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
+ --> tests/unit_tests/services/hit_service.py:431:24
+ERROR Cannot index into `object` [bad-index]
+ --> tests/unit_tests/services/hit_service.py:432:20
ERROR Cannot index into `str` [bad-index]
--> tests/unit_tests/services/hit_service.py:432:20
ERROR Cannot index into `dict[str, str]` [bad-index]
--> tests/unit_tests/services/hit_service.py:432:38
+ERROR Cannot index into `object` [bad-index]
+ --> tests/unit_tests/services/hit_service.py:433:20
ERROR Cannot index into `str` [bad-index]
--> tests/unit_tests/services/hit_service.py:433:20
ERROR Cannot index into `dict[str, str]` [bad-index]
--> tests/unit_tests/services/hit_service.py:433:38
+ERROR Cannot index into `object` [bad-index]
+ --> tests/unit_tests/services/hit_service.py:434:20
ERROR Cannot index into `str` [bad-index]
--> tests/unit_tests/services/hit_service.py:434:20
ERROR Cannot index into `dict[str, str]` [bad-index]
--> tests/unit_tests/services/hit_service.py:434:38
ERROR Cannot index into `list[Unknown]` [bad-index]
--> tests/unit_tests/services/hit_service.py:461:16
+ERROR Cannot index into `object` [bad-index]
+ --> tests/unit_tests/services/hit_service.py:461:16
ERROR Cannot index into `list[Unknown]` [bad-index]
--> tests/unit_tests/services/hit_service.py:496:20
+ERROR Cannot index into `object` [bad-index]
+ --> tests/unit_tests/services/hit_service.py:496:20
+ERROR Argument `dict[str, str] | list[Unknown] | object` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
+ --> tests/unit_tests/services/hit_service.py:497:24
ERROR Cannot index into `list[Unknown]` [bad-index]
--> tests/unit_tests/services/hit_service.py:530:20
+ERROR Cannot index into `object` [bad-index]
+ --> tests/unit_tests/services/hit_service.py:530:20
ERROR Object of class `Marketplace` has no attribute `repo`
ERROR Object of class `FunctionType` has no attribute `call_args` [missing-attribute]
--> tests/unit_tests/services/plugin/test_oauth_service.py:50:34
|
asukaminato0721
approved these changes
Apr 3, 2026
HanqingZ
pushed a commit
to HanqingZ/dify
that referenced
this pull request
Apr 23, 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.
Summary
QueryDictandRetrieveResponseDictTypedDicts tohit_testing_service.pycompact_retrieve_responseandcompact_external_retrieve_response(previouslydict[Any, Any])Why this change
Both methods construct dicts with the same fixed shape (
query.content+recordslist) but were typed asdict[Any, Any]— the weakest possible dict annotation. A TypedDict makes the response contract explicit.Changes
hit_testing_service.py: Define 2 TypedDicts, update 2 method return typesTest plan
ruff checkpassesPart of #32863 (
services/hit_testing_service.py)