def get_last_lineno(node):
    """Recursively find the last line number of the ast node."""
    max_lineno = 0

    if hasattr(node, "lineno"):
        max_lineno = node.lineno

    for _, field in ast.iter_fields(node):
        if isinstance(field, list):
            for value in field:
                if isinstance(value, ast.AST):
                    max_lineno = max(max_lineno, get_last_lineno(value))

        elif isinstance(field, ast.AST):
            max_lineno = max(max_lineno, get_last_lineno(field))

    return max_lineno
def get_last_lineno ( node ) : max_lineno = 0 if hasattr ( node , "lineno" ) : max_lineno = node . lineno for _ , field in ast . iter_fields ( node ) : if isinstance ( field , list ) : for value in field : if isinstance ( value , ast . AST ) : max_lineno = max ( max_lineno , get_last_lineno ( value ) ) elif isinstance ( field , ast . AST ) : max_lineno = max ( max_lineno , get_last_lineno ( field ) ) return max_lineno
Recursively find the last line number of the ast node.