Skip to content

refactor(api): type hit testing retrieve responses with TypedDict#34484

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:refactor/typed-dict-hit-testing-service
Apr 3, 2026
Merged

refactor(api): type hit testing retrieve responses with TypedDict#34484
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:refactor/typed-dict-hit-testing-service

Conversation

@YB0y
Copy link
Copy Markdown
Contributor

@YB0y YB0y commented Apr 2, 2026

Summary

  • Add QueryDict and RetrieveResponseDict TypedDicts to hit_testing_service.py
  • Annotate return types of compact_retrieve_response and compact_external_retrieve_response (previously dict[Any, Any])

Why this change

Both methods construct dicts with the same fixed shape (query.content + records list) but were typed as dict[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 types

Test plan

  • ruff check passes

Part of #32863 (services/hit_testing_service.py)

@YB0y YB0y requested a review from JohnJyong as a code owner April 2, 2026 15:28
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Pyrefly Diff

base → 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

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 3, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 3, 2026
Merged via the queue into langgenius:main with commit 71d299d Apr 3, 2026
27 checks passed
@YB0y YB0y deleted the refactor/typed-dict-hit-testing-service branch April 8, 2026 13:35
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 refactor size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants