custom_rules.py 文件源码

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

项目:warriorframework 作者: warriorframework 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号