Operating system: macOS Mojave 10.14.4 (18E226)
Python version: Python 3.7.3
Black version: 19.3b0
Does also happen on master: yes (957ba24bb6cdd32e4dd14ff2808dcf4d58851844)
Reproducers:
Source:
result = (
1 # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
)
Black diff:
--- source
+++ first pass
@@ -1,4 +1,2 @@
-result = (
- 1 # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-)
+result = 1 # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
--- first pass
+++ second pass
@@ -1,2 +1,4 @@
-result = 1 # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+result = (
+ 1
+) # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Source:
result = (
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # aaa
)
Black diff:
--- source
+++ first pass
@@ -1,4 +1,2 @@
-result = (
- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # aaa
-)
+result = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # aaa
--- first pass
+++ second pass
@@ -1,2 +1,4 @@
-result = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # aaa
+result = (
+ "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+) # aaa
I'm not sure what you're saying but 1 and (1) are the same code. It's not a tuple unless it's got a trailing comma like (1,).
Is this about how the comments are placed?
@thalessa the bug is that Black is producing unstable formatting -- the formatter should be idempotent and here it is not. Black itself will alert you to this situation with the error message quoted in the title of this issue: "different code" in this context really means "the same code, differently formatted."
Most helpful comment
@thalessa the bug is that Black is producing unstable formatting -- the formatter should be idempotent and here it is not. Black itself will alert you to this situation with the error message quoted in the title of this issue: "different code" in this context really means "the same code, differently formatted."