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

Return annotations #147

Closed
RedKhan opened this issue Jan 14, 2019 · 2 comments
Closed

Return annotations #147

RedKhan opened this issue Jan 14, 2019 · 2 comments

Comments

@RedKhan
Copy link

RedKhan commented Jan 14, 2019

Hi guys, I ran into a problem where Baron interprets the "-" in the "->" of a function's return annotation as a minus instead of as part of an arrow.

def foo() -> int: return 3

baron.parser.ParsingError: Error, got an unexpected token MINUS here:
1 def foo() -<---- here
The token MINUS should be one of those: COLON

Very cool project by the way; would be nice to use something like RB in combination with support for annotations to enable some proper static analysis of functions, maybe even hijack some ideas from Haskell.

@lordmauve
Copy link

Cannot reproduce with baron==0.9:

>>> baron.parse('def foo() -> int: return 3')
[{'type': 'def', 'async': False, 'return_annotation': {'type': 'name', 'value': 'int'}, 'return_annotation_first_formatting': [{'type': 'space', 'value': ' '}], 'return_annotation_second_formatting': [{'type': 'space', 'value': ' '}], 'async_formatting': [], 'decorators': [], 'name': 'foo', 'first_formatting': [{'type': 'space', 'value': ' '}], 'second_formatting': [], 'third_formatting': [], 'fourth_formatting': [], 'fifth_formatting': [], 'sixth_formatting': [{'type': 'space', 'value': ' '}], 'arguments': [], 'value': [{'type': 'return', 'value': {'type': 'int', 'value': '3', 'section': 'number'}, 'formatting': [{'type': 'space', 'value': ' '}]}, {'type': 'endl', 'value': '\n', 'formatting': [], 'indent': ''}]}]
>>> baron.dumps(_)
'def foo() -> int: return 3\n'

@RedKhan
Copy link
Author

RedKhan commented Mar 30, 2019

uninstalling and re-installing baron to upgrade to 0.9 resolved the problem for me.

@RedKhan RedKhan closed this as completed Apr 6, 2019
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

2 participants