py-ast - v1.16.0
    Preparing search index...

    Function copyLocation

    Parser entry points and location-manipulation helpers.

    • parse / parseFile — parse Python source (or a file on disk) into an AST.
    • literalEval — safely evaluate a literal expression node, mirroring ast.literal_eval.
    • fixMissingLocations — fill in missing lineno/col_offset info on a hand-built tree by copying it from parent nodes.
    • copyLocation — copy location info from one node to another.
    • incrementLineno — shift every line number in a tree by an offset.
    • ParseOptions — options accepted by parse.
    • Copies source-location fields (lineno, col_offset, end_lineno, end_col_offset) from oldNode onto newNode, mirroring CPython's ast.copy_location. Useful when synthesizing or replacing AST nodes that must retain their original position for error reporting.

      Parameters

      • newNode: ASTNode

        The node to receive the location.

      • oldNode: ASTNode

        The node to copy the location from.

      Returns ASTNode

      newNode, mutated in place.