def assign_location(target: Expression, source: Expression): # set statement target.statement = source.statement # set parents target.parent = source.parent target.annotated_type.parent = target source.parent = target # set source location target.line = source.line target.column = source.column
def visitExpression(self, ast: Expression): parent = ast while parent and not isinstance(parent, Statement): parent = parent.parent if parent: ast.statement = parent