stmt_inferrer.py 文件源码

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

项目:Typpete 作者: caterinaurban 项目源码 文件源码
def is_stub(node):
    """Check if the function is a stub definition:

    For the function to be a stub, it should be fully annotated and should have no body.
    The body should be a single `Pass` statement with optional docstring.
    """
    if not is_annotated(node):
        return False

    if len(node.body) == 1 and isinstance(node.body[0], ast.Expr) and isinstance(node.body[0].value, ast.Ellipsis):
        return True
    return ((len(node.body) == 1 and isinstance(node.body[0], ast.Pass))
            or (len(node.body) == 2 and isinstance(node.body[0], ast.Expr) and isinstance(node.body[1], ast.Pass)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号