]> git.madduck.net Git - etc/vim.git/blobdiff - black.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:

Add trailing comma when a single import doesn't fit on a line. (#504)
[etc/vim.git] / black.py
index 56765313aa85b0571c7831f209573bd2b3fbb955..f76f0ffc24cfcf237d13fcc19f5492635158c4c4 100644 (file)
--- a/black.py
+++ b/black.py
@@ -2209,7 +2209,7 @@ def left_hand_split(line: Line, py36: bool = False) -> Iterator[Line]:
             yield result
 
 
-def right_hand_split(
+def right_hand_split(  # noqa C901
     line: Line, line_length: int, py36: bool = False, omit: Collection[LeafID] = ()
 ) -> Iterator[Line]:
     """Split line into many lines, starting with the last matching bracket pair.
@@ -2250,6 +2250,9 @@ def right_hand_split(
         # the matching `opening_bracket` wasn't available on `line` anymore.
         raise CannotSplit("No brackets found")
 
+    if line.is_import and len(body_leaves) == 1:
+        body_leaves.append(Leaf(token.COMMA, ","))
+
     # Build the new lines.
     for result, leaves in (head, head_leaves), (body, body_leaves), (tail, tail_leaves):
         for leaf in leaves: