]> 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 crash with long type annotations (#1093)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Sun, 27 Oct 2019 11:31:10 +0000 (04:31 -0700)
committerZsolt Dollenstein <zsol.zsol@gmail.com>
Sun, 27 Oct 2019 11:31:10 +0000 (11:31 +0000)
black.py
tests/data/function_trailing_comma.py

index ada9b0efe1b989500cb05c1959440eca7be0f8e4..5b2e0171c484d2ed5d94ad3066d4fb2a13068ce7 100644 (file)
--- a/black.py
+++ b/black.py
@@ -2601,9 +2601,11 @@ def bracket_split_build_line(
             # Since body is a new indent level, remove spurious leading whitespace.
             normalize_prefix(leaves[0], inside_brackets=True)
             # Ensure a trailing comma for imports and standalone function arguments, but
-            # be careful not to add one after any comments.
-            no_commas = original.is_def and not any(
-                l.type == token.COMMA for l in leaves
+            # be careful not to add one after any comments or within type annotations.
+            no_commas = (
+                original.is_def
+                and opening_bracket.value == "("
+                and not any(l.type == token.COMMA for l in leaves)
             )
 
             if original.is_import or no_commas:
index f2594c68ae246743348851d860ccdd8d78fd2ede..fcd81ad7d9689e74d856cd1e75b1d1c3ef7557b1 100644 (file)
@@ -4,6 +4,11 @@ def f(a,):
 def f(a:int=1,):
     ...
 
+def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[
+    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+]:
+    pass
+
 # output
 
 def f(a,):
@@ -12,3 +17,9 @@ def f(a,):
 
 def f(a: int = 1,):
     ...
+
+
+def xxxxxxxxxxxxxxxxxxxxxxxxxxxx() -> Set[
+    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+]:
+    pass