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)))
评论列表
文章目录