Skip to content

Unsupported positional-only argument syntax #218

@hydrargyrum

Description

@hydrargyrum

This syntax works fine in python:

def foo(a, /, b): pass

but redbaron fails to parse it:

>>> redbaron.RedBaron("def foo(a, /, b): pass")
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/baron/baron.py", line 20, in _parse
    return parser(tokens)
  File "/usr/lib/python3/dist-packages/baron/grammator.py", line 836, in parse
    return parser.parse(iter(tokens))
  File "/usr/lib/python3/dist-packages/baron/parser.py", line 165, in parse
    raise ParsingError(debug_output)
baron.parser.ParsingError: Error, got an unexpected token SLASH here:

   1 def foo(a, /<---- here

The token SLASH should be one of those: COMMA, DOUBLE_STAR, LEFT_PARENTHESIS, NAME, RIGHT_PARENTHESIS, STAR

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 "/usr/lib/python3/dist-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 "/usr/lib/python3/dist-packages/baron/baron.py", line 57, in parse
    to_return = _parse(tokens, print_function)
  File "/usr/lib/python3/dist-packages/baron/baron.py", line 24, in _parse
    return parser(tokens)
  File "/usr/lib/python3/dist-packages/baron/grammator.py", line 836, in parse
    return parser.parse(iter(tokens))
  File "/usr/lib/python3/dist-packages/baron/parser.py", line 165, in parse
    raise ParsingError(debug_output)
baron.parser.ParsingError: Error, got an unexpected token SLASH here:

   1 def foo(a, /<---- here

The token SLASH should be one of those: COMMA, DOUBLE_STAR, LEFT_PARENTHESIS, NAME, RIGHT_PARENTHESIS, STAR

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions