这条意见建设性吗

👁️ 3 人浏览 💬 0 人评论 ❤️ 添加收藏

按评审模型,一条意见 suggestion=True, reason=True,is_constructive 交回什么?

贯穿本节的评审意见模型:一条意见是 dict(suggestion, reason, severity)。is_constructive=既给了具体建议又说了为什么;severity ∈ {nit, suggest, block},blocking(意见表) 数几条 block;can_merge(意见表, 批准数)=有人批准且没有 block。

def is_constructive(comment):
    # 建设性意见:既给了具体建议、又说了为什么
    return comment.get("suggestion", False) and comment.get("reason", False)


def blocking(comments):
    # 数有几条「拦路」的意见(severity == "block")
    return sum(1 for c in comments if c.get("severity") == "block")


def can_merge(comments, approvals):
    # 有人批准、且没有拦路意见,才能合
    return approvals >= 1 and blocking(comments) == 0

print(is_constructive({"suggestion": True, "reason": True}))
提交你的答案
请登录后提交答案。
去登录
代码编辑器
Ctrl + Enter 运行
本次输入:
输出:

                        
👩‍🏫
AI
💬 题目评论

全部评论