(tree: ast.AST, node: ast.AST)
Get node position with non-Exp parent.
Get node position with non-Exp parent.
Get node position with non - Exp parent .
def get_node_position(tree: ast.AST, node: ast.AST) -> NodePosition:
    """Get node position with non-Exp parent."""
    parent = get_parent(tree, node)

    while not hasattr(parent, 'body') and not hasattr(parent, 'orelse'):
        node = parent
        parent = get_parent(tree, parent)

    if node in parent.body:  # type: ignore
        return NodePosition(parent, 'body', parent.body,  # type: ignore
                            parent.body.index(node))  # type: ignore
    else:
        return NodePosition(parent, 'orelse', parent.orelse,  # type: ignore
                            parent.orelse.index(node))
def get_node_position ( tree : ast . AST , node : ast . AST ) -> NodePosition : parent = get_parent ( tree , node ) while not hasattr ( parent , 'body' ) and not hasattr ( parent , 'orelse' ) : node = parent parent = get_parent ( tree , parent ) if node in parent . body : # type: ignore return NodePosition ( parent , 'body' , parent . body , # type: ignore parent . body . index ( node ) ) # type: ignore else : return NodePosition ( parent , 'orelse' , parent . orelse , # type: ignore parent . orelse . index ( node ) )