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

print fixer adds parens to already-parened print #178

Open
benbariteau opened this issue Feb 28, 2019 · 4 comments
Open

print fixer adds parens to already-parened print #178

benbariteau opened this issue Feb 28, 2019 · 4 comments

Comments

@benbariteau
Copy link

given

print('foo')

the print fixer will change it to:

print(('foo'))

While not incorrect, it's definitely a little odd.

@benbariteau
Copy link
Author

To be clear this is when from __future__ import print_function is not present initially.

@asottile
Copy link
Member

asottile commented Apr 8, 2019

this is a bug in lib2to3 fwiw:

$ python3.8 -m lib2to3 -f print t.py
RefactoringTool: Refactored t.py
--- t.py	(original)
+++ t.py	(refactored)
@@ -1 +1 @@
-print("foo{}".format(1))
+print(("foo{}".format(1)))
RefactoringTool: Files that need to be modified:
RefactoringTool: t.py

@asottile
Copy link
Member

asottile commented Apr 8, 2019

since it's fairly common to end up in this state, I'm adding a fixer for this in pyupgrade: asottile/pyupgrade#122

@takluyver
Copy link
Contributor

Nice project :-). We've kind of split 2to3 into two tools - modernize when you want to add Python 3 support, and pyupgrade with the --py3-plus flag (from looking at your README) when you want to drop Python 2 support.

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

3 participants