def class_check(node, kw=False):
'''
Class specific check
Action - check private method, move to utils
check docstring
scan for class - recursive class check
scan for function - function check
'''
status = True
for child in ast.iter_child_nodes(node):
if isinstance(child, ast.FunctionDef):
if kw and child.name.startswith("_") and child.name != "__init__":
print node.name, child.name, "should move to utils"
status = False
tmp_status = func_check(child, kw)
status &= tmp_status
elif isinstance(child, ast.ClassDef):
tmp_status = class_check(child, kw)
status &= tmp_status
if ast.get_docstring(node) is None:
# check for docstring
print node.name, "doesn't contain any docstring"
status = False
return status
评论列表
文章目录