Skip to content

refactor(api): type load balancing config dicts with TypedDict#34639

Merged
asukaminato0721 merged 7 commits intolanggenius:mainfrom
statxc:refactor/typed-dict-load-balancing-config
Apr 7, 2026
Merged

refactor(api): type load balancing config dicts with TypedDict#34639
asukaminato0721 merged 7 commits intolanggenius:mainfrom
statxc:refactor/typed-dict-load-balancing-config

Conversation

@statxc
Copy link
Copy Markdown
Contributor

@statxc statxc commented Apr 7, 2026

Part of #32863 (api/services/model_load_balancing_service.py)

Summary

  • Add LoadBalancingConfigDetailDict TypedDict with keys id, name, credentials, enabled
  • Add LoadBalancingConfigSummaryDict TypedDict with keys id, name, credentials, credential_id, enabled, in_cooldown, ttl
  • Annotate return types of get_load_balancing_configs and get_load_balancing_config

Why this change

Both methods return dicts with well-known fixed keys but were typed as list[dict] and dict | None.
The TypedDicts make the shape explicit.

Changes

  • api/services/model_load_balancing_service.py: Define 2 TypedDicts, update 2 method signatures

@statxc statxc requested a review from QuantumGhost as a code owner April 7, 2026 04:24
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-07 04:25:51.448268726 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-07 04:25:43.072321568 +0000
@@ -349,6 +349,8 @@
   --> services/plugin/plugin_migration.py:91:34
 ERROR Object of class `dict` has no attribute `encode`
 ERROR Object of class `dict` has no attribute `encode`
+ERROR Returned type `list[LoadBalancingConfigSummaryDict]` is not assignable to declared return type `list[dict[Unknown, Unknown]]` [bad-return]
+   --> services/workflow_service.py:664:20
 ERROR Returned type `EndUser | Unknown | None` is not assignable to declared return type `Account | EndUser` [bad-return]
    --> tasks/app_generate/workflow_execute_task.py:219:24
 ERROR `Account | Unknown | None` is not assignable to `Account` [bad-assignment]

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Pyrefly Diff

No changes detected.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-07 04:41:33.632166179 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-07 04:41:25.075219111 +0000
@@ -349,6 +349,8 @@
   --> services/plugin/plugin_migration.py:91:34
 ERROR Object of class `dict` has no attribute `encode`
 ERROR Object of class `dict` has no attribute `encode`
+ERROR Returned type `list[LoadBalancingConfigSummaryDict]` is not assignable to declared return type `list[dict[Unknown, Unknown]]` [bad-return]
+   --> services/workflow_service.py:664:20
 ERROR Returned type `EndUser | Unknown | None` is not assignable to declared return type `Account | EndUser` [bad-return]
    --> tasks/app_generate/workflow_execute_task.py:219:24
 ERROR `Account | Unknown | None` is not assignable to `Account` [bad-assignment]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-07 04:46:46.469443533 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-07 04:46:38.140484097 +0000
@@ -349,6 +349,8 @@
   --> services/plugin/plugin_migration.py:91:34
 ERROR Object of class `dict` has no attribute `encode`
 ERROR Object of class `dict` has no attribute `encode`
+ERROR Returned type `list[LoadBalancingConfigSummaryDict]` is not assignable to declared return type `list[dict[str, Any]]` [bad-return]
+   --> services/workflow_service.py:664:20
 ERROR Returned type `EndUser | Unknown | None` is not assignable to declared return type `Account | EndUser` [bad-return]
    --> tasks/app_generate/workflow_execute_task.py:219:24
 ERROR `Account | Unknown | None` is not assignable to `Account` [bad-assignment]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-07 05:01:19.644721032 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-07 05:01:11.074659674 +0000
@@ -349,6 +349,8 @@
   --> services/plugin/plugin_migration.py:91:34
 ERROR Object of class `dict` has no attribute `encode`
 ERROR Object of class `dict` has no attribute `encode`
+ERROR `list[LoadBalancingConfigSummaryDict]` is not assignable to `list[dict[str, Any]]` [bad-assignment]
+   --> services/workflow_service.py:662:49
 ERROR Returned type `EndUser | Unknown | None` is not assignable to declared return type `Account | EndUser` [bad-return]
    --> tasks/app_generate/workflow_execute_task.py:219:24
 ERROR `Account | Unknown | None` is not assignable to `Account` [bad-assignment]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Pyrefly Diff

No changes detected.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 7, 2026

Pyrefly Diff

No changes detected.

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 7, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 7, 2026
Merged via the queue into langgenius:main with commit 63db9a7 Apr 7, 2026
26 of 27 checks passed
@statxc statxc deleted the refactor/typed-dict-load-balancing-config branch April 7, 2026 11:21
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 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