有几条拦路意见
按评审模型,两条 block、一条 nit,blocking 交回几?
评审模型:is_constructive=有具体建议 + 讲了为什么;blocking=几条拦路(severity=block);ready_to_merge(意见, 批准数)=有批准且无拦路才能合。
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 ready_to_merge(comments, approvals):
"""有人批准、且没有拦路意见,才能合。"""
return approvals >= 1 and blocking(comments) == 0
print(blocking([{"severity": "block"}, {"severity": "nit"}, {"severity": "block"}]))
全部评论