Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for walrus operator #216

Open
elijahr opened this issue Oct 4, 2022 · 0 comments
Open

support for walrus operator #216

elijahr opened this issue Oct 4, 2022 · 0 comments

Comments

@elijahr
Copy link

elijahr commented Oct 4, 2022

The walrus operator which was added in Python 3.8 (:=) is not supported:

>>> import redbaron
>>> redbaron.RedBaron('''
... if foo := True:
...     print(foo)
... ''')
Traceback (most recent call last):
  File "~/.asdf/installs/python/3.10.7/lib/python3.10/site-packages/baron/baron.py", line 20, in _parse
    return parser(tokens)
  File "~/.asdf/installs/python/3.10.7/lib/python3.10/site-packages/baron/grammator.py", line 836, in parse
    return parser.parse(iter(tokens))
  File "~/.asdf/installs/python/3.10.7/lib/python3.10/site-packages/baron/parser.py", line 165, in parse
    raise ParsingError(debug_output)
baron.parser.ParsingError: Error, got an unexpected token EQUAL here:

   1
   2 if foo := <---- here

The token EQUAL should be one of those: ASSERT, BACKQUOTE, BINARY, BINARY_RAW_STRING, BINARY_STRING, BREAK, COMMENT, COMPLEX, CONTINUE, DEL, ELLIPSIS, ENDL, EXEC, FLOAT, FLOAT_EXPONANT, FLOAT_EXPONANT_COMPLEX, FROM, GLOBAL, HEXA, IMPORT, INT, INTERPOLATED_RAW_STRING, INTERPOLATED_STRING, LAMBDA, LEFT_BRACKET, LEFT_PARENTHESIS, LEFT_SQUARE_BRACKET, LONG, MINUS, NAME, NONLOCAL, NOT, OCTA, PASS, PLUS, PRINT, RAISE, RAW_STRING, RETURN, STAR, STRING, TILDE, UNICODE_RAW_STRING, UNICODE_STRING, YIELD

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 baron 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.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/.asdf/installs/python/3.10.7/lib/python3.10/site-packages/redbaron/redbaron.py", line 36, in __init__
    self.node_list = base_nodes.NodeList.from_fst(baron.parse(source_code), parent=self, on_attribute="root")
  File "~/.asdf/installs/python/3.10.7/lib/python3.10/site-packages/baron/baron.py", line 66, in parse
    return _parse(tokens, print_function)
  File "~/.asdf/installs/python/3.10.7/lib/python3.10/site-packages/baron/baron.py", line 24, in _parse
    return parser(tokens)
  File "~/.asdf/installs/python/3.10.7/lib/python3.10/site-packages/baron/grammator.py", line 836, in parse
    return parser.parse(iter(tokens))
  File "~/.asdf/installs/python/3.10.7/lib/python3.10/site-packages/baron/parser.py", line 165, in parse
    raise ParsingError(debug_output)
baron.parser.ParsingError: Error, got an unexpected token EQUAL here:

   1
   2 if foo := <---- here

The token EQUAL should be one of those: ASSERT, BACKQUOTE, BINARY, BINARY_RAW_STRING, BINARY_STRING, BREAK, COMMENT, COMPLEX, CONTINUE, DEL, ELLIPSIS, ENDL, FLOAT, FLOAT_EXPONANT, FLOAT_EXPONANT_COMPLEX, FROM, GLOBAL, HEXA, IMPORT, INT, INTERPOLATED_RAW_STRING, INTERPOLATED_STRING, LAMBDA, LEFT_BRACKET, LEFT_PARENTHESIS, LEFT_SQUARE_BRACKET, LONG, MINUS, NAME, NONLOCAL, NOT, OCTA, PASS, PLUS, RAISE, RAW_STRING, RETURN, STAR, STRING, TILDE, UNICODE_RAW_STRING, UNICODE_STRING, YIELD

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 baron 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant