replacing a call atom with a comprehension raises ParsingError
graingert opened this issue · 0 comments
graingert commented
>>> red = redbaron.RedBaron("filter(fn, items).pop()")
>>> red[0]
filter(fn, items).pop()
>>> del red[0][1]
>>> red
0 filter.pop()
>>> red[0][0] = "[x for x in items if fn(x)]"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/redacted/.virtualenvs/redbaron/local/lib/python/site-packages/redbaron/base_nodes.py", line 736, in __setitem__
self.value[key] = value
File "/home/redacted/.virtualenvs/redbaron/local/lib/python/site-packages/redbaron/base_nodes.py", line 1469, in __setitem__
on_attribute=self.on_attribute)
File "/home/redacted/.virtualenvs/redbaron/local/lib/python/site-packages/redbaron/base_nodes.py", line 1672, in _convert_input_to_node_object
return self.node_list.parent._convert_input_to_node_object_list(value, parent, on_attribute).filtered()[-1]
File "/home/redacted/.virtualenvs/redbaron/local/lib/python/site-packages/redbaron/base_nodes.py", line 188, in _convert_input_to_node_object_list
return self._string_to_node_list(value, parent=parent, on_attribute=on_attribute)
File "/home/redacted/.virtualenvs/redbaron/local/lib/python/site-packages/redbaron/nodes.py", line 98, in _string_to_node_list
return NodeList.from_fst(baron.parse("(%s)" % string)[0]["value"]["value"], parent=parent, on_attribute=on_attribute)
File "/home/redacted/.virtualenvs/redbaron/local/lib/python/site-packages/baron/baron.py", line 57, in parse
to_return = _parse(tokens, print_function)
File "/home/redacted/.virtualenvs/redbaron/local/lib/python/site-packages/baron/baron.py", line 24, in _parse
return parser(tokens)
File "/home/redacted/.virtualenvs/redbaron/local/lib/python/site-packages/baron/grammator.py", line 828, in parse
return parser.parse(iter(tokens))
File "/home/redacted/.virtualenvs/redbaron/local/lib/python/site-packages/baron/parser.py", line 167, in parse
raise ParsingError(debug_output)
baron.parser.ParsingError: Error, got an unexpected token FOR here:
1 (a[x for <---- here
The token FOR should be one of those: COLON, COMMA, RIGHT_SQUARE_BRACKET
Baron has failed to parse this input. If this is valid python code (and by that I mean that the python binary successfully parse this code without any syntax error) (also consider that python does not yet parse python 3 code integrally) it would be kind if you can extract a snippet of your code that make Baron fails and open a bug here: https://github.com/PyCQA/baron/issues
Sorry for the inconvenience.