Skip to content

refactor(api): type pipeline template retrieval dicts with TypedDict#34874

Merged
asukaminato0721 merged 4 commits intolanggenius:mainfrom
YB0y:refactor/typed-dict-pipeline-template-retrieval
Apr 17, 2026
Merged

refactor(api): type pipeline template retrieval dicts with TypedDict#34874
asukaminato0721 merged 4 commits intolanggenius:mainfrom
YB0y:refactor/typed-dict-pipeline-template-retrieval

Conversation

@YB0y
Copy link
Copy Markdown
Contributor

@YB0y YB0y commented Apr 10, 2026

Part of #32863 (api/services/rag_pipeline/pipeline_template/)

Summary

  • Add CustomizedTemplateItemDict, CustomizedTemplatesResultDict, CustomizedTemplateDetailDict TypedDicts to customized_retrieval.py
  • Add PipelineTemplateItemDict, PipelineTemplatesResultDict, PipelineTemplateDetailDict TypedDicts to database_retrieval.py
  • Tighten bare dict to dict[str, Any] in pipeline_template_base.py, built_in_retrieval.py, and remote_retrieval.py

Why this change

fetch_pipeline_templates_from_db, fetch_pipeline_template_detail_from_db, and their customized counterparts return dicts with well-known fixed keys but were typed as bare dict. The TypedDicts make the shape explicit and enable static type checking.

Changes

  • customized_retrieval.py: Define 3 TypedDicts, update 4 method signatures and local annotations
  • database_retrieval.py: Define 3 TypedDicts, update 4 method signatures and local annotations
  • pipeline_template_base.py: Tighten abstract signatures from dict to dict[str, Any]
  • built_in_retrieval.py: Tighten dict to dict[str, Any] (JSON-loaded data, not a TypedDict candidate)
  • remote_retrieval.py: Tighten dict to dict[str, Any] (external API data), simplify control flow

@YB0y YB0y requested a review from JohnJyong as a code owner April 10, 2026 00:24
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. refactor labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 00:25:20.914123291 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 00:25:11.049071822 +0000
@@ -333,6 +333,18 @@
   --> services/hit_testing_service.py:94:21
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
   --> services/plugin/plugin_migration.py:91:34
+ERROR Class member `CustomizedPipelineTemplateRetrieval.get_pipeline_templates` overrides parent class `PipelineTemplateRetrievalBase` in an inconsistent manner [bad-override]
+  --> services/rag_pipeline/pipeline_template/customized/customized_retrieval.py:42:9
+ERROR Class member `CustomizedPipelineTemplateRetrieval.get_pipeline_template_detail` overrides parent class `PipelineTemplateRetrievalBase` in an inconsistent manner [bad-override]
+  --> services/rag_pipeline/pipeline_template/customized/customized_retrieval.py:46:9
+ERROR Class member `DatabasePipelineTemplateRetrieval.get_pipeline_templates` overrides parent class `PipelineTemplateRetrievalBase` in an inconsistent manner [bad-override]
+  --> services/rag_pipeline/pipeline_template/database/database_retrieval.py:42:9
+ERROR Class member `DatabasePipelineTemplateRetrieval.get_pipeline_template_detail` overrides parent class `PipelineTemplateRetrievalBase` in an inconsistent manner [bad-override]
+  --> services/rag_pipeline/pipeline_template/database/database_retrieval.py:45:9
+ERROR Returned type `PipelineTemplateDetailDict | None` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
+  --> services/rag_pipeline/pipeline_template/remote/remote_retrieval.py:24:20
+ERROR Returned type `PipelineTemplatesResultDict` is not assignable to declared return type `dict[str, Any]` [bad-return]
+  --> services/rag_pipeline/pipeline_template/remote/remote_retrieval.py:31:20
 ERROR `dict[str, Any]` is not assignable to attribute `credentials` with type `Never` [bad-assignment]
    --> services/trigger/trigger_provider_service.py:446:40
 ERROR `int` is not assignable to attribute `credential_expires_at` with type `Never` [bad-assignment]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-10 00:46:12.559064720 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-10 00:46:03.599081023 +0000
@@ -329,6 +329,18 @@
   --> services/hit_testing_service.py:94:21
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
   --> services/plugin/plugin_migration.py:91:34
+ERROR Returned type `CustomizedTemplatesResultDict` is not assignable to declared return type `dict[str, Any]` [bad-return]
+  --> services/rag_pipeline/pipeline_template/customized/customized_retrieval.py:44:16
+ERROR Returned type `CustomizedTemplateDetailDict | None` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
+  --> services/rag_pipeline/pipeline_template/customized/customized_retrieval.py:47:16
+ERROR Returned type `PipelineTemplatesResultDict` is not assignable to declared return type `dict[str, Any]` [bad-return]
+  --> services/rag_pipeline/pipeline_template/database/database_retrieval.py:43:16
+ERROR Returned type `PipelineTemplateDetailDict | None` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
+  --> services/rag_pipeline/pipeline_template/database/database_retrieval.py:46:16
+ERROR Returned type `PipelineTemplateDetailDict | None` is not assignable to declared return type `dict[str, Any] | None` [bad-return]
+  --> services/rag_pipeline/pipeline_template/remote/remote_retrieval.py:24:20
+ERROR Returned type `PipelineTemplatesResultDict` is not assignable to declared return type `dict[str, Any]` [bad-return]
+  --> services/rag_pipeline/pipeline_template/remote/remote_retrieval.py:31:20
 ERROR `dict[str, Any]` is not assignable to attribute `credentials` with type `Never` [bad-assignment]
    --> services/trigger/trigger_provider_service.py:446:40
 ERROR `int` is not assignable to attribute `credential_expires_at` with type `Never` [bad-assignment]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

No changes detected.

@YB0y YB0y force-pushed the refactor/typed-dict-pipeline-template-retrieval branch from 19ee223 to 06da87f Compare April 14, 2026 04:55
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

No changes detected.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 17, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 17, 2026
Merged via the queue into langgenius:main with commit 0020aa8 Apr 17, 2026
28 checks passed
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:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants