we-like-parsers / cpython

Here we work on integrating pegen into CPython; use branch 'pegen'
https://github.com/gvanrossum/pegen
Other
1 stars 0 forks source link

Fix adding empty Constant node after FormattedValue #164

Closed lysnikolaou closed 3 years ago

lysnikolaou commented 3 years ago

Before this PR, there was an empty Constant node after the FormattedValue node even for a simple f-string like f'{a}':

>>> f = 'f"{a}"'
>>> ast.dump(ast.parse(f))
"Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='a', ctx=Load()), conversion=-1), Constant(value='')]))], type_ignores=[])"

With this PR:

>>> f = 'f"{a}"'
>>> ast.dump(ast.parse(f))
"Module(body=[Expr(value=JoinedStr(values=[FormattedValue(value=Name(id='a', ctx=Load()), conversion=-1)]))], type_ignores=[])"
pablogsal commented 3 years ago

@lysnikolaou Does this need to wait until #149 is landed?

lysnikolaou commented 3 years ago

@pablogsal This can go already before #149, I think.

pablogsal commented 3 years ago

Yes!!