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

parenthesis around expressions in a JoinedString #153

Closed
ikamensh opened this issue Aug 1, 2019 · 1 comment · Fixed by #155
Closed

parenthesis around expressions in a JoinedString #153

ikamensh opened this issue Aug 1, 2019 · 1 comment · Fixed by #155

Comments

@ikamensh
Copy link

ikamensh commented Aug 1, 2019

Astor wraps expressions into parenthesis, also when this is completely redundant:

code = '''print(f"{var + 1:.2f}")'''

import ast
tree = ast.parse(code)
import astor
recovered = astor.to_source(tree)

print('original:   ',code)
print('astor:      ',recovered)

output:

original:    print(f"{var + 1:.2f}")
astor:       print(f'{(var + 1):.2f}')

Python: 3.6.8
astor: 0.8.0

@isidentical
Copy link
Contributor

Just saw, preparing patch (sorry for delay).

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

Successfully merging a pull request may close this issue.

2 participants