]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Back out #850 (#1079)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Sun, 20 Oct 2019 16:02:17 +0000 (09:02 -0700)
committerGitHub <noreply@github.com>
Sun, 20 Oct 2019 16:02:17 +0000 (09:02 -0700)
Fixes #1042 (and probably #1044 which looks like the same thing).

The issue with the "obviously unnecessary" parentheses that #850 removed is that sometimes they're necessary to help Black fit something in one line. I didn't see an obvious solution that still removes the parens #850 was intended to remove, so let's back out this change for now in the interest of unblocking a release.

This PR also adds a test adapted from the failing example in #1042, so that if we try to reapply the #850 change we don't break the same case again.

black.py
tests/data/expression.diff
tests/data/expression.py
tests/data/remove_parens.py

index 3842be9641e3045ed9f236df7e4f97ee42290e52..151c1a6b32de27f0e40bd0011668af4040d678aa 100644 (file)
--- a/black.py
+++ b/black.py
@@ -1714,26 +1714,6 @@ class LineGenerator(Visitor[Line]):
                 self.current_line.append(node)
         yield from super().visit_default(node)
 
                 self.current_line.append(node)
         yield from super().visit_default(node)
 
-    def visit_atom(self, node: Node) -> Iterator[Line]:
-        # Always make parentheses invisible around a single node, because it should
-        # not be needed (except in the case of yield, where removing the parentheses
-        # produces a SyntaxError).
-        if (
-            len(node.children) == 3
-            and isinstance(node.children[0], Leaf)
-            and node.children[0].type == token.LPAR
-            and isinstance(node.children[2], Leaf)
-            and node.children[2].type == token.RPAR
-            and isinstance(node.children[1], Leaf)
-            and not (
-                node.children[1].type == token.NAME
-                and node.children[1].value == "yield"
-            )
-        ):
-            node.children[0].value = ""
-            node.children[2].value = ""
-        yield from super().visit_default(node)
-
     def visit_factor(self, node: Node) -> Iterator[Line]:
         """Force parentheses between a unary op and a binary power:
 
     def visit_factor(self, node: Node) -> Iterator[Line]:
         """Force parentheses between a unary op and a binary power:
 
index da20094cc1ea688ae4a2a0748c54f10a3d872c86..629e1012f87fda20c44a82c1d58c0e2ed3c86192 100644 (file)
 +{"2.7": dead, "3.7": long_live or die_hard}
 +{"2.7", "3.6", "3.7", "3.8", "3.9", "4.0" if gilectomy else "3.10"}
  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
 +{"2.7": dead, "3.7": long_live or die_hard}
 +{"2.7", "3.6", "3.7", "3.8", "3.9", "4.0" if gilectomy else "3.10"}
  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
--(SomeName)
-+SomeName
+ (SomeName)
  SomeName
  (Good, Bad, Ugly)
  (i for i in (1, 2, 3))
  SomeName
  (Good, Bad, Ugly)
  (i for i in (1, 2, 3))
index c9b149ffa80044f5afe88cb8da6dcacf3623bfe4..3bcf52b54c4907ba81ca14c9f0ac83826e4b0375 100644 (file)
@@ -424,7 +424,7 @@ numpy[np.newaxis, :]
 {"2.7": dead, "3.7": long_live or die_hard}
 {"2.7", "3.6", "3.7", "3.8", "3.9", "4.0" if gilectomy else "3.10"}
 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
 {"2.7": dead, "3.7": long_live or die_hard}
 {"2.7", "3.6", "3.7", "3.8", "3.9", "4.0" if gilectomy else "3.10"}
 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 or A, 11 or B, 12 or C]
-SomeName
+(SomeName)
 SomeName
 (Good, Bad, Ugly)
 (i for i in (1, 2, 3))
 SomeName
 (Good, Bad, Ugly)
 (i for i in (1, 2, 3))
index e128f59518a78ef8e91f5d3d5826616cccc75a1a..afc34010c30f9bc1c4aca176a4faa6d27d70fe02 100644 (file)
@@ -1,8 +1,19 @@
-print((1))
 x = (1)
 x = (1.2)
 x = (1)
 x = (1.2)
-(x) = (3)
 
 
+data = (
+    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+).encode()
+
+async def show_status():
+    while True:
+        try:
+            if report_host:
+                data = (
+                   f"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+               ).encode()
+        except Exception as e:
+            pass
 
 def example():
     return (("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))
 
 def example():
     return (("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"))
@@ -45,10 +56,23 @@ def example8():
 
 
 # output
 
 
 # output
-print(1)
 x = 1
 x = 1.2
 x = 1
 x = 1.2
-x = 3
+
+data = (
+    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+).encode()
+
+
+async def show_status():
+    while True:
+        try:
+            if report_host:
+                data = (
+                    f"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+                ).encode()
+        except Exception as e:
+            pass
 
 
 def example():
 
 
 def example():