]> git.madduck.net Git - etc/vim.git/blobdiff - src/black/__init__.py

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:

Update all dependencies to latest versions
[etc/vim.git] / src / black / __init__.py
index b660e4788b496fd36e7868dca308a35dcf60c63d..391233ed4485e16dc6798c2d041412dd8c5e1c82 100644 (file)
@@ -3297,12 +3297,12 @@ class StringParenStripper(StringTransformer):
             # if the leaves in the parsed string include a PERCENT, we need to
             # make sure the initial LPAR is NOT preceded by an operator with
             # higher or equal precedence to PERCENT
-            if (
-                is_valid_index(idx - 2)
-                and token.PERCENT in {leaf.type for leaf in LL[idx - 1 : next_idx]}
-                and (
+            if is_valid_index(idx - 2):
+                # mypy can't quite follow unless we name this
+                before_lpar = LL[idx - 2]
+                if token.PERCENT in {leaf.type for leaf in LL[idx - 1 : next_idx]} and (
                     (
-                        LL[idx - 2].type
+                        before_lpar.type
                         in {
                             token.STAR,
                             token.AT,
@@ -3318,12 +3318,12 @@ class StringParenStripper(StringTransformer):
                     )
                     or (
                         # only unary PLUS/MINUS
-                        not is_valid_index(idx - 3)
-                        and (LL[idx - 2].type in {token.PLUS, token.MINUS})
+                        before_lpar.parent
+                        and before_lpar.parent.type == syms.factor
+                        and (before_lpar.type in {token.PLUS, token.MINUS})
                     )
-                )
-            ):
-                continue
+                ):
+                    continue
 
             # Should be followed by a non-empty RPAR...
             if (