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

Fix a crash in ESP where a standalone comment is placed before a dict's value (#3469)
authorYilei "Dolee" Yang <yileiyang@google.com>
Tue, 20 Dec 2022 22:59:38 +0000 (14:59 -0800)
committerGitHub <noreply@github.com>
Tue, 20 Dec 2022 22:59:38 +0000 (14:59 -0800)
CHANGES.md
src/black/trans.py
tests/data/preview/long_strings__regression.py

index c29933fe5d9c9ae85ce980d96d1aeb7131e6c289..1e51f3e9108f9b86e473663656f38c8e74d1ce7e 100644 (file)
@@ -21,6 +21,8 @@
   and except clauses (#3423)
 - Fix a crash in preview advanced string processing where mixed implicitly concatenated
   regular and f-strings start with an empty span (#3463)
   and except clauses (#3423)
 - Fix a crash in preview advanced string processing where mixed implicitly concatenated
   regular and f-strings start with an empty span (#3463)
+- Fix a crash in preview advanced string processing where a standalone comment is placed
+  before a dict's value (#3469)
 - Do not put the closing quotes in a docstring on a separate line, even if the line is
   too long (#3430)
 - Long values in dict literals are now wrapped in parentheses; correspondingly
 - Do not put the closing quotes in a docstring on a separate line, even if the line is
   too long (#3430)
 - Long values in dict literals are now wrapped in parentheses; correspondingly
index a5cf4955f1318616563de6c980586ccc55b15d57..0eb53e2b09877652bcfa12e6399dbd1937930aa1 100644 (file)
@@ -1866,7 +1866,7 @@ class StringParenWrapper(BaseStringSplitter, CustomSplitMapMixin):
 
             for i, leaf in enumerate(LL):
                 # We MUST find a colon, it can either be dict's or lambda's colon...
 
             for i, leaf in enumerate(LL):
                 # We MUST find a colon, it can either be dict's or lambda's colon...
-                if leaf.type == token.COLON:
+                if leaf.type == token.COLON and i < len(LL) - 1:
                     idx = i + 2 if is_empty_par(LL[i + 1]) else i + 1
 
                     # That colon MUST be followed by a string...
                     idx = i + 2 if is_empty_par(LL[i + 1]) else i + 1
 
                     # That colon MUST be followed by a string...
index 5e8f012bc3e9f9d009ed446cb1a6354bbce22fcf..ef9007f4ce11b04f8d72204d876e72e03780f7aa 100644 (file)
@@ -543,6 +543,13 @@ xxxx(
     f'xxxxxxxxxxxxx xxxx xx xxxxxxxxxx. xxxxx: {x.xxx}',
 )
 
     f'xxxxxxxxxxxxx xxxx xx xxxxxxxxxx. xxxxx: {x.xxx}',
 )
 
+# Regression test for https://github.com/psf/black/issues/3455.
+a_dict = {
+    "/this/is/a/very/very/very/very/very/very/very/very/very/very/long/key/without/spaces":
+        # And there is a comment before the value
+        ("item1", "item2", "item3"),
+}
+
 
 # output
 
 
 # output
 
@@ -1221,3 +1228,10 @@ xxxx(
         f"xxxxxxxxxxxxx xxxx xx xxxxxxxxxx. xxxxx: {x.xxx}"
     ),
 )
         f"xxxxxxxxxxxxx xxxx xx xxxxxxxxxx. xxxxx: {x.xxx}"
     ),
 )
+
+# Regression test for https://github.com/psf/black/issues/3455.
+a_dict = {
+    "/this/is/a/very/very/very/very/very/very/very/very/very/very/long/key/without/spaces":
+    # And there is a comment before the value
+    ("item1", "item2", "item3"),
+}