pylama_mccabe.py 文件源码

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

项目:wuye.vim 作者: zhaoyingnan911 项目源码 文件源码
def run(path, code=None, params=None, **meta):
        """MCCabe code checking.

        :return list: List of errors.
        """
        try:
            tree = compile(code, path, "exec", ast.PyCF_ONLY_AST)
        except SyntaxError as exc:
            return [{'lnum': exc.lineno, 'text': 'Invalid syntax: %s' % exc.text.strip()}]

        McCabeChecker.max_complexity = int(params.get('complexity', 10))
        return [
            {'lnum': lineno, 'offset': offset, 'text': text, 'type': McCabeChecker._code}
            for lineno, offset, text, _ in McCabeChecker(tree, path).run()
        ]

#  pylama:ignore=W0212
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号