Describe the bug
Under preview, the removal of unnecessary parenthesizes can be unstable if there's multiple -- each pass removes only one pair.
To Reproduce
For example, take this code:
for ((x, y)) in enumerate(range(10)):
pass
And run it with these arguments:
$ black file.py --preview
The resulting error is:
error: cannot format test.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /tmp/blk_473_benq.log
Oh no! 💥 💔 💥
1 file would fail to reformat.
Mode(target_versions={<TargetVersion.PY38: 8>, <TargetVersion.PY37: 7>, <TargetVersion.PY36: 6>}, line_length=88, string_normalization=True, is_pyi=False, is_ipynb=False, magic_trailing_comma=True, experimental_string_processing=False, python_cell_magics=set(), preview=True)
--- source
+++ first pass
@@ -1,2 +1,2 @@
-for ((x, y)) in enumerate(range(10)):
+for (x, y) in enumerate(range(10)):
pass
--- first pass
+++ second pass
@@ -1,2 +1,2 @@
-for (x, y) in enumerate(range(10)):
+for x, y in enumerate(range(10)):
pass
Expected behavior
All of the unnecessary parenthesizes being removed at once ^^
Environment
- Black's version: 14d84ba
- OS and Python version: CPython 3.8.5
Describe the bug
Under preview, the removal of unnecessary parenthesizes can be unstable if there's multiple -- each pass removes only one pair.
To Reproduce
For example, take this code:
And run it with these arguments:
The resulting error is:
Expected behavior
All of the unnecessary parenthesizes being removed at once ^^
Environment