]> 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:

Don't remove the single trailing comma from square bracket indexing
authorŁukasz Langa <lukasz@langa.pl>
Thu, 22 Mar 2018 23:33:50 +0000 (16:33 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Thu, 22 Mar 2018 23:33:50 +0000 (16:33 -0700)
Fixes #59

black.py
tests/expression.py

index d3e0761e273a58fe4b7318827e12bbd853f53eea..877b632f3a54c3a5893290c1447c6221f73c1f68 100644 (file)
--- a/black.py
+++ b/black.py
@@ -510,10 +510,16 @@ class Line:
         ):
             return False
 
-        if closing.type == token.RSQB or closing.type == token.RBRACE:
+        if closing.type == token.RBRACE:
             self.leaves.pop()
             return True
 
+        if closing.type == token.RSQB:
+            comma = self.leaves[-1]
+            if comma.parent and comma.parent.type == syms.listmaker:
+                self.leaves.pop()
+                return True
+
         # For parens let's check if it's safe to remove the comma.  If the
         # trailing one is the only one, we might mistakenly change a tuple
         # into a different type by removing the comma.
index 91e5465440799856479837e4f73e56ec2fe7e83e..79e7c7ecef70327bba591e6f3057baa6dcb980b4 100644 (file)
@@ -53,6 +53,7 @@ str or None if (1 if True else 2) else str or bytes or None
 (1, 2, 3)
 []
 [1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
+[1, 2, 3,]
 {i for i in (1, 2, 3)}
 {(i ** 2) for i in (1, 2, 3)}
 {(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))}
@@ -84,7 +85,10 @@ call.me(maybe)
 list[str]
 dict[str, int]
 tuple[str, ...]
-tuple[str, int, float, dict[str, int]]
+tuple[str, int, float, dict[str, int],]
+very_long_variable_name_filters: t.List[
+    t.Tuple[str, t.Union[str, t.List[t.Optional[str]]]],
+]
 slice[0]
 slice[0:1]
 slice[0:1:2]
@@ -207,6 +211,7 @@ str or None if (1 if True else 2) else str or bytes or None
 (1, 2, 3)
 []
 [1, 2, 3, 4, 5, 6, 7, 8, 9, (10 or A), (11 or B), (12 or C)]
+[1, 2, 3]
 {i for i in (1, 2, 3)}
 {(i ** 2) for i in (1, 2, 3)}
 {(i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))}
@@ -248,6 +253,9 @@ list[str]
 dict[str, int]
 tuple[str, ...]
 tuple[str, int, float, dict[str, int]]
+very_long_variable_name_filters: t.List[
+    t.Tuple[str, t.Union[str, t.List[t.Optional[str]]]],
+]
 slice[0]
 slice[0:1]
 slice[0:1:2]