python类YieldFrom()的实例源码

bugbear.py 文件源码 项目:flake8-bugbear 作者: PyCQA 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def check_for_b901(self, node):
        xs = list(node.body)
        has_yield = False
        return_node = None
        while xs:
            x = xs.pop()
            if isinstance(x, (ast.AsyncFunctionDef, ast.FunctionDef)):
                continue
            elif isinstance(x, (ast.Yield, ast.YieldFrom)):
                has_yield = True
            elif isinstance(x, ast.Return) and x.value is not None:
                return_node = x

            if has_yield and return_node is not None:
                self.errors.append(
                    B901(return_node.lineno, return_node.col_offset)
                )
                break

            xs.extend(ast.iter_child_nodes(x))
yield_to_yield_from.py 文件源码 项目:opyum 作者: Amper 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def visit_For(self, node: ast.For):
        node = self.generic_visit(node)
        if self._is_for_yield(node):
            yield_node = ast.YieldFrom(value = node.iter)
            expr_node = ast.Expr(value = yield_node)
            node = ast.copy_location(expr_node, node)
            node = ast.fix_missing_locations(node)
        return node
test_ast.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_yield(self):
        self.expr(ast.Yield(ast.Name("x", ast.Store())), "must have Load")
        self.expr(ast.YieldFrom(ast.Name("x", ast.Store())), "must have Load")
test_ast.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def test_yield(self):
        self.expr(ast.Yield(ast.Name("x", ast.Store())), "must have Load")
        self.expr(ast.YieldFrom(ast.Name("x", ast.Store())), "must have Load")
test_ast.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def test_yield(self):
        self.expr(ast.Yield(ast.Name("x", ast.Store())), "must have Load")
        self.expr(ast.YieldFrom(ast.Name("x", ast.Store())), "must have Load")
functions.py 文件源码 项目:metapensiero.pj 作者: azazel75 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _isyield(el):
    return isinstance(el, (ast.Yield, ast.YieldFrom))
function.py 文件源码 项目:peval 作者: fjarri 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def is_a_generator(function):
    return has_nodes(function.tree, (ast.Yield, ast.YieldFrom))


问题


面经


文章

微信
公众号

扫码关注公众号