import redbaron
with open('test.py', 'r') as f:
ast = redbaron.RedBaron(f.read())
xs = ast.find('CallArgumentNode').value.value
for x in xs:
print x.to_python()
Expect "foo" to be printed.
Actually get:
Traceback (most recent call last):
File "rb.py", line 8, in <module>
print x.to_python()
File "/Users/dwh/.virtualenv/redbaron/lib/python2.7/site-packages/redbaron/base_nodes.py", line 136, in to_python
return ast.literal_eval(self.dumps())
File "/opt/homebrew/Cellar/python27/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 49, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "/opt/homebrew/Cellar/python27/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 37, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 2
^
IndentationError: unexpected indent
Adding a trailing comma after "foo" makes this work, but isn't required by python.
Analysing the same list but as a top-level assignment rather than a kwarg value works fine.
Python being analysed:
Code using redbaron:
Expect "foo" to be printed. Actually get:
Adding a trailing comma after "foo" makes this work, but isn't required by python. Analysing the same list but as a top-level assignment rather than a kwarg value works fine.