shairubin / fun_with_ast

let's have fun manipulating ASTs in Python
Apache License 2.0
0 stars 1 forks source link

list index out of range - jstr new #291

Closed shairubin closed 1 month ago

shairubin commented 1 month ago

class NodeInjector:

def _get_source_code_to_add(self):

raise NotImplementedError('abstract method')

def _get_source_code_to_add(self, node):
    for index, line in enumerate(lines):
        source_to_add += line + self.source_suffix.removesuffix('\n') + f'_{index}' + '\n'
    return source_to_add