refactor(api): type load balancing config dicts with TypedDict#34639
Merged
asukaminato0721 merged 7 commits intolanggenius:mainfrom Apr 7, 2026
Merged
Conversation
Contributor
Pyrefly Diffbase → 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]
|
Contributor
Pyrefly DiffNo changes detected. |
Contributor
Pyrefly Diffbase → 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]
|
Contributor
Pyrefly Diffbase → 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]
|
Contributor
Pyrefly Diffbase → 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]
|
Contributor
Pyrefly DiffNo changes detected. |
Contributor
Pyrefly DiffNo changes detected. |
asukaminato0721
approved these changes
Apr 7, 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.
Part of #32863 (
api/services/model_load_balancing_service.py)Summary
LoadBalancingConfigDetailDictTypedDict with keysid,name,credentials,enabledLoadBalancingConfigSummaryDictTypedDict with keysid,name,credentials,credential_id,enabled,in_cooldown,ttlget_load_balancing_configsandget_load_balancing_configWhy this change
Both methods return dicts with well-known fixed keys but were typed as
list[dict]anddict | None.The TypedDicts make the shape explicit.
Changes
api/services/model_load_balancing_service.py: Define 2 TypedDicts, update 2 method signatures