Skip to content

fix: 获取作品评论source参数无效 #525#527

Closed
diudiu62 wants to merge 1 commit intoJoeanAmier:developfrom
diudiu62:develop
Closed

fix: 获取作品评论source参数无效 #525#527
diudiu62 wants to merge 1 commit intoJoeanAmier:developfrom
diudiu62:develop

Conversation

@diudiu62
Copy link

@safe1ine
Copy link

safe1ine commented Feb 5, 2026

@MonkeyCode-AI 帮忙 review

@MonkeyCode-AI
Copy link

MonkeyCode-AI 正在分析任务...

Copy link

@MonkeyCode-AI MonkeyCode-AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我是 MonkeyCode AI 编程助手,你可以在 GitHub 仓库的 PR 中 at @MonkeyCode-AI 来呼唤我。

任务执行细节请参考: https://monkeycode-ai.com

代码审查结果

本次修改补齐了 /douyin/comment 接口对 source 参数的透传,并在终端侧支持按需返回原始评论数据,能修复“source 参数无效”的问题,但需尽快补齐接口文档与默认值一致性。

🚨 Critical ⚠️ Warning 💡 Suggestion
0 2 0

count=extract.count,
count_reply=extract.count_reply,
reply=extract.reply,
source=extract.source,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

⚠️ /douyin/comment 接口文档未包含 source 参数,且缩进出现多余空行

本次在调用 comment_handle_single() 时新增了 source=extract.source,但该接口的 description 中没有列出 source 参数(与 detail/account/live 等接口不一致),会导致使用方不知道该参数可用。另外在参数列表中插入了一个空行,影响可读性。

建议: 在 /douyin/comment 的接口 description 中补充 source 参数说明,并移除多余空行,保持参数传递风格一致。

Suggested change
source=extract.source,
if data := await self.comment_handle_single(
extract.detail_id,
cookie=extract.cookie,
proxy=extract.proxy,
pages=extract.pages,
cursor=extract.cursor,
count=extract.count,
count_reply=extract.count_reply,
reply=extract.reply,
source=extract.source,
):

detail_id: str,
cookie: str = None,
proxy: str = None,
source=False,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

⚠️ comment_handle_single 新增参数 source 的默认值类型建议使用 bool 注解并与其它接口对齐

comment_handle_single 新增了 source=False,但未做类型注解;同时该类中其它类似开关参数多处使用 source=False / api=False 的模式,建议统一为 source: bool = False,提升可读性与 IDE/类型检查体验。

建议: 为 source 增加 bool 类型注解,并保持签名风格一致。

Suggested change
source=False,
async def comment_handle_single(
self,
detail_id: str,
cookie: str = None,
proxy: str = None,
source: bool = False,
**kwargs,
) -> list:
if data := await Comment(
self.parameter,
cookie,
proxy,
detail_id=detail_id,
**kwargs,
).run():
return data if source else await self.save_comment(detail_id, data)
return []

@JoeanAmier JoeanAmier closed this Feb 5, 2026
Copy link

@MonkeyCode-AI MonkeyCode-AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我是 MonkeyCode AI 编程助手,你可以在 GitHub 仓库的 PR 中 at @MonkeyCode-AI 来呼唤我。

任务执行细节请参考: https://monkeycode-ai.com

代码审查结果

本次修复将 comment 接口的 source 参数正确透传到 comment_handle_single,并在终端侧支持 source=True 时直接返回原始评论数据,整体符合 PR 目的且影响面小。

🚨 Critical ⚠️ Warning 💡 Suggestion
0 1 1

detail_id: str,
cookie: str = None,
proxy: str = None,
source=False,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

⚠️ source 参数缺少类型标注且默认值为裸 bool,建议显式声明以提升可读性/静态检查效果

comment_handle_single 新增 source=False,但未标注类型。该方法本身返回 list,source 控制返回“原始数据”或“保存后的提取结果”,属于关键行为开关,建议显式标注为 bool,并在签名中保持参数顺序/风格一致(如其他方法也有 source: bool = False)。

建议: 为 source 添加 bool 类型标注,并保持默认值为 False。

Suggested change
source=False,
async def comment_handle_single(
self,
detail_id: str,
cookie: str = None,
proxy: str = None,
source: bool = False,
**kwargs,
) -> list:

count=extract.count,
count_reply=extract.count_reply,
reply=extract.reply,
source=extract.source,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

💡 多余空行导致格式不一致

handle_comment 调用 comment_handle_single 时在参数列表末尾出现额外空行,虽然不影响运行,但与文件其余位置风格不一致,建议移除以保持整洁。

建议: 删除参数列表中的多余空行。

Suggested change
source=extract.source,
if data := await self.comment_handle_single(
extract.detail_id,
cookie=extract.cookie,
proxy=extract.proxy,
pages=extract.pages,
cursor=extract.cursor,
count=extract.count,
count_reply=extract.count_reply,
reply=extract.reply,
source=extract.source,
):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants