Skip to content

find_ast_node

faststream.utils.ast.find_ast_node #

find_ast_node(module, lineno)
Source code in faststream/utils/ast.py
def find_ast_node(module: ast.Module, lineno: Optional[int]) -> Optional[ast.AST]:
    if lineno is not None:  # pragma: no branch
        for i in getattr(module, "body", ()):
            if i.lineno == lineno:
                return cast(ast.AST, i)

            r = find_ast_node(i, lineno)
            if r is not None:
                return r

    return None