bugbear.py 文件源码

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

项目:flake8-bugbear 作者: PyCQA 项目源码 文件源码
def visit_Assign(self, node):
        if isinstance(self.node_stack[-2], ast.ClassDef):
            # note: by hasattr below we're ignoring starred arguments, slices
            # and tuples for simplicity.
            assign_targets = {t.id for t in node.targets if hasattr(t, 'id')}
            if '__metaclass__' in assign_targets:
                self.errors.append(
                    B303(node.lineno, node.col_offset)
                )
        elif len(node.targets) == 1:
            t = node.targets[0]
            if isinstance(t, ast.Attribute) and isinstance(t.value, ast.Name):
                if (t.value.id, t.attr) == ('os', 'environ'):
                    self.errors.append(
                        B003(node.lineno, node.col_offset)
                    )
        self.generic_visit(node)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号