print fixer adds parens to already-parened print
benbariteau opened this issue · 4 comments
benbariteau commented
given
print('foo')
the print
fixer will change it to:
print(('foo'))
While not incorrect, it's definitely a little odd.
benbariteau commented
To be clear this is when from __future__ import print_function
is not present initially.
asottile commented
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 commented
since it's fairly common to end up in this state, I'm adding a fixer for this in pyupgrade: asottile/pyupgrade#122
takluyver commented
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.