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

Account for += assignment when deciding whether to split string (#2312)
authorBryan Bugyi <bryanbugyi34@gmail.com>
Mon, 7 Jun 2021 14:01:57 +0000 (10:01 -0400)
committerGitHub <noreply@github.com>
Mon, 7 Jun 2021 14:01:57 +0000 (07:01 -0700)
Fixes #2294

CHANGES.md
src/black/trans.py
tests/data/long_strings__edge_case.py
tests/data/long_strings__regression.py

index 16d9ebc3fe5fbaf50ae4e4e14c61644ff8e56894..84f156d903de00ac5ad9b486e37b4808361a52a3 100644 (file)
@@ -4,6 +4,7 @@
 
 ### _Black_
 
 
 ### _Black_
 
+- Account for += assignment when deciding whether to split string (#2312)
 - Correct max string length calculation when there are string operators (#2292)
 - Fixed option usage when using the `--code` flag (#2259)
 - Do not call `uvloop.install()` when _Black_ is used as a library (#2303)
 - Correct max string length calculation when there are string operators (#2292)
 - Fixed option usage when using the `--code` flag (#2259)
 - Do not call `uvloop.install()` when _Black_ is used as a library (#2303)
index bc6e93b01b40706c4f19d8ee053664c105812712..d56205d4598bef11e27e4d0486ba1f1e2d95f629 100644 (file)
@@ -867,7 +867,7 @@ class BaseStringSplitter(StringTransformer):
                 # WMA4 a space, a comma, and a closing bracket [e.g. `), STRING`].
                 offset += 3
 
                 # WMA4 a space, a comma, and a closing bracket [e.g. `), STRING`].
                 offset += 3
 
-            if P.type in [token.COLON, token.EQUAL, token.NAME]:
+            if P.type in [token.COLON, token.EQUAL, token.PLUSEQUAL, token.NAME]:
                 # This conditional branch is meant to handle dictionary keys,
                 # variable assignments, 'return STRING' statement lines, and
                 # 'else STRING' ternary expression lines.
                 # This conditional branch is meant to handle dictionary keys,
                 # variable assignments, 'return STRING' statement lines, and
                 # 'else STRING' ternary expression lines.
index 07c275371911b5732072cfa67241592f61bf55cb..2bc0b6ed32885a7bac4c816d6bcd3c3e4ce6fcca 100644 (file)
@@ -32,6 +32,9 @@ return f'{x}/b/c/d/d/d/dadfjsadjsaidoaisjdsfjaofjdfijaidfjaodfjaoifjodjafojdoaja
 assert str(result) == "This long string should be split at some point right close to or around hereeeeeee"
 assert str(result) < "This long string should be split at some point right close to or around hereeeeee"
 assert "A format string: %s" % "This long string should be split at some point right close to or around hereeeeeee" != result
 assert str(result) == "This long string should be split at some point right close to or around hereeeeeee"
 assert str(result) < "This long string should be split at some point right close to or around hereeeeee"
 assert "A format string: %s" % "This long string should be split at some point right close to or around hereeeeeee" != result
+msg += "This long string should be wrapped in parens at some point right around hereeeee"
+msg += "This long string should be split at some point right close to or around hereeeeeeee"
+msg += "This long string should not be split at any point ever since it is just righttt"
 
 
 # output
 
 
 # output
@@ -127,3 +130,11 @@ assert (
     " hereeeeeee"
     != result
 )
     " hereeeeeee"
     != result
 )
+msg += (
+    "This long string should be wrapped in parens at some point right around hereeeee"
+)
+msg += (
+    "This long string should be split at some point right close to or around"
+    " hereeeeeeee"
+)
+msg += "This long string should not be split at any point ever since it is just righttt"
index cd8053f9eb5813627f5c2c26a3fdb2dde80f6297..d46f96a82d0694c6ebe5baf917209039562fd1d1 100644 (file)
@@ -407,6 +407,16 @@ def _legacy_listen_examples():
     )
 
 
     )
 
 
+class X:
+    async def foo(self):
+        msg = ""
+        for candidate in CANDIDATES:
+            msg += (
+                "**{candidate.object_type} {candidate.rev}**"
+                " - {candidate.description}\n"
+            )
+
+
 temp_msg = (
     f"{f'{humanize_number(pos)}.': <{pound_len+2}} "
     f"{balance: <{bal_len + 5}} "
 temp_msg = (
     f"{f'{humanize_number(pos)}.': <{pound_len+2}} "
     f"{balance: <{bal_len + 5}} "
@@ -948,6 +958,16 @@ def _legacy_listen_examples():
     )
 
 
     )
 
 
+class X:
+    async def foo(self):
+        msg = ""
+        for candidate in CANDIDATES:
+            msg += (
+                "**{candidate.object_type} {candidate.rev}**"
+                " - {candidate.description}\n"
+            )
+
+
 temp_msg = (
     f"{f'{humanize_number(pos)}.': <{pound_len+2}} "
     f"{balance: <{bal_len + 5}} "
 temp_msg = (
     f"{f'{humanize_number(pos)}.': <{pound_len+2}} "
     f"{balance: <{bal_len + 5}} "