-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
C: unstable formattingFormatting changed on the second passFormatting changed on the second passF: parenthesesToo many parentheses, not enough parentheses, and so on.Too many parentheses, not enough parentheses, and so on.T: bugSomething isn't workingSomething isn't working
Description
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)):
passAnd run it with these arguments:
$ black file.py --previewThe 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C: unstable formattingFormatting changed on the second passFormatting changed on the second passF: parenthesesToo many parentheses, not enough parentheses, and so on.Too many parentheses, not enough parentheses, and so on.T: bugSomething isn't workingSomething isn't working