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

Support sticky standalone comments (comments preceding defs, classes, and decorators)
[etc/vim.git] / black.py
index a03b9aad7607ffd4107b22b6382b6a00028d204c..11386d23f9df76ad9b57129ea2bb28eba4792f5d 100644 (file)
--- a/black.py
+++ b/black.py
@@ -1040,12 +1040,14 @@ class EmptyLineTracker:
                 # Don't insert empty lines before the first line in the file.
                 return 0, 0
 
                 # Don't insert empty lines before the first line in the file.
                 return 0, 0
 
-            if self.previous_line and self.previous_line.is_decorator:
-                # Don't insert empty lines between decorators.
+            if self.previous_line.is_decorator:
                 return 0, 0
 
                 return 0, 0
 
-            if is_decorator and self.previous_line and self.previous_line.is_comment:
-                # Don't insert empty lines between decorator comments.
+            if (
+                self.previous_line.is_comment
+                and self.previous_line.depth == current_line.depth
+                and before == 0
+            ):
                 return 0, 0
 
             newlines = 2
                 return 0, 0
 
             newlines = 2