bugbear.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:flake8-bugbear 作者: PyCQA 项目源码 文件源码
def check_for_b901(self, node):
        xs = list(node.body)
        has_yield = False
        return_node = None
        while xs:
            x = xs.pop()
            if isinstance(x, (ast.AsyncFunctionDef, ast.FunctionDef)):
                continue
            elif isinstance(x, (ast.Yield, ast.YieldFrom)):
                has_yield = True
            elif isinstance(x, ast.Return) and x.value is not None:
                return_node = x

            if has_yield and return_node is not None:
                self.errors.append(
                    B901(return_node.lineno, return_node.col_offset)
                )
                break

            xs.extend(ast.iter_child_nodes(x))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号