Skip to content

refactor: add missing @override decorators to agent composer API classes#36504

Open
guangyang1206 wants to merge 2 commits into
langgenius:mainfrom
guangyang1206:batch1-contribution
Open

refactor: add missing @override decorators to agent composer API classes#36504
guangyang1206 wants to merge 2 commits into
langgenius:mainfrom
guangyang1206:batch1-contribution

Conversation

@guangyang1206
Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue and you have been assigned to it
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

做了什么

api/controllers/console/agent/composer.py 中的所有 Resource 子类的 HTTP 方法添加了 @override 装饰器。

具体影响的类和方法:

  • WorkflowAgentComposerApi: get(), put()
  • WorkflowAgentComposerValidateApi: post()
  • WorkflowAgentComposerCandidatesApi: get()
  • WorkflowAgentComposerImpactApi: post()
  • WorkflowAgentComposerSaveToRosterApi: post()
  • AgentAppComposerApi: get(), put()
  • AgentAppComposerValidateApi: post()
  • AgentAppComposerCandidatesApi: get()

为什么这么做

  1. 代码质量: @override 装饰器明确标识了哪些方法是重写父类方法,提高代码可读性
  2. 类型检查: 帮助 mypy/pyright 进行更准确的类型检查,捕获潜在的拼写错误
  3. 一致性: 此改动延续了最近多个 PR 的模式(refactor: add missing @override decorator to AppQueueManager subclasses #36490, refactor: add missing @override decorator to GraphEngineLayer subclasses #36491, refactor: add missing @override decorator to Moderation subclasses #36492, refactor: add missing @override decorator to PluginModelRuntime #36493, refactor: add missing @override decorator to datasource plugin classes #36494, refactor: add missing @override decorator to file access controller and workflow file runtime #36495, refactor: add missing @override decorator to code executor providers and transformers #36496),保持代码库风格一致
  4. 防止错误: 如果父类方法签名变更,子类没有相应更新,@override 装饰器会帮助捕获这类问题

改动文件

  • api/controllers/console/agent/composer.py: 为 8 个 Resource 子类的 11 个方法添加了 @override 装饰器,并添加了 from typing import override 导入

测试

由于这是纯装饰器添加(不改变运行时行为),现有测试应该全部通过。建议运行:

pytest api/tests/unit_tests/controllers/console/agent/

关联

Follow-up to #36490, #36491, #36492, #36493, #36494, #36495, #36496

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels May 22, 2026
@asukaminato0721 asukaminato0721 enabled auto-merge May 22, 2026 03:16
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-05-22 03:20:25.996829494 +0000
+++ /tmp/pyrefly_pr.txt	2026-05-22 03:20:17.505763611 +0000
@@ -1,3 +1,13 @@
+ERROR Class member `WorkflowAgentComposerApi.get` is marked as an override, but no parent class has a matching attribute [bad-override]
+  --> controllers/console/agent/composer.py:25:9
+ERROR Class member `WorkflowAgentComposerCandidatesApi.get` is marked as an override, but no parent class has a matching attribute [bad-override]
+  --> controllers/console/agent/composer.py:73:9
+ERROR Class member `WorkflowAgentComposerImpactApi.post` is marked as an override, but no parent class has a matching attribute [bad-override]
+  --> controllers/console/agent/composer.py:84:9
+ERROR Class member `AgentAppComposerApi.get` is marked as an override, but no parent class has a matching attribute [bad-override]
+   --> controllers/console/agent/composer.py:121:9
+ERROR Class member `AgentAppComposerCandidatesApi.get` is marked as an override, but no parent class has a matching attribute [bad-override]
+   --> controllers/console/agent/composer.py:164:9
 ERROR `str` is not assignable to `Literal['advanced-chat', 'agent-chat', 'all', 'channel', 'chat', 'completion', 'workflow']` [bad-assignment]
   --> controllers/console/app/app.py:70:104
 ERROR Object of class `App` has no attribute `access_mode` [missing-attribute]

@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 44.90% 44.90% 0.00%
Strict coverage 44.42% 44.42% 0.00%
Typed symbols 23,110 23,110 0
Untyped symbols 28,667 28,667 0
Modules 2611 2611 0

@asukaminato0721 asukaminato0721 disabled auto-merge May 22, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant