Open stuaxo opened 4 years ago
I've started playing with astor and ASTs, and noticed astor doesn't populate ctx when using dump_tree, this makes means there is an extra step to fill this out before the output can be used for NodeTransformer etc.
ctx
dump_tree
Astor dump - no ctx:
print(astor.dump_tree(parse('a = variables[1]'))) Module( body=[ Assign(targets=[Name(id='a')], value=Subscript(value=Name(id='variables'), slice=Index(value=Constant(value=1, kind=None))), type_comment=None)], type_ignores=[])
dump_tree from greentreesnakes:
print(dump(parse('a = variables[1]'))) Module(body=[ Assign(targets=[ Name(id='a', ctx=Store()), ], value=Subscript(value=Name(id='variables', ctx=Load()), slice=Index(value=Constant(value=1, kind=None)), ctx=Load()), type_comment=None), ], type_ignores=[])
I've started playing with astor and ASTs, and noticed astor doesn't populate
ctx
when usingdump_tree
, this makes means there is an extra step to fill this out before the output can be used for NodeTransformer etc.Astor dump - no ctx:
dump_tree from greentreesnakes: