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

Formatting nits
authorŁukasz Langa <lukasz@langa.pl>
Mon, 7 May 2018 17:22:43 +0000 (10:22 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Mon, 7 May 2018 17:22:43 +0000 (10:22 -0700)
black.py
tests/class_blank_parentheses.py

index cfb5028d68d85be324c450838f7797ecbe22e5fd..46754566fd4aaac239b93c0250fd9c12da2c9d39 100644 (file)
--- a/black.py
+++ b/black.py
@@ -743,9 +743,8 @@ class Line:
         if not has_value:
             return
 
         if not has_value:
             return
 
-        if token.COLON == leaf.type and self.is_class_parenth_empty:
+        if token.COLON == leaf.type and self.is_class_paren_empty:
             del self.leaves[-2:]
             del self.leaves[-2:]
-
         if self.leaves and not preformatted:
             # Note: at this point leaf.prefix should be empty except for
             # imports, for which we only preserve newlines.
         if self.leaves and not preformatted:
             # Note: at this point leaf.prefix should be empty except for
             # imports, for which we only preserve newlines.
@@ -755,7 +754,6 @@ class Line:
         if self.inside_brackets or not preformatted:
             self.bracket_tracker.mark(leaf)
             self.maybe_remove_trailing_comma(leaf)
         if self.inside_brackets or not preformatted:
             self.bracket_tracker.mark(leaf)
             self.maybe_remove_trailing_comma(leaf)
-
         if not self.append_comment(leaf):
             self.leaves.append(leaf)
 
         if not self.append_comment(leaf):
             self.leaves.append(leaf)
 
@@ -844,8 +842,11 @@ class Line:
         )
 
     @property
         )
 
     @property
-    def is_class_parenth_empty(self) -> bool:
-        """Is this class parentheses blank?"""
+    def is_class_paren_empty(self) -> bool:
+        """Is this a class with no base classes but using parentheses?
+
+        Those are unnecessary and should be removed.
+        """
         return (
             bool(self)
             and len(self.leaves) == 4
         return (
             bool(self)
             and len(self.leaves) == 4
@@ -1141,7 +1142,6 @@ class LineGenerator(Visitor[Line]):
 
         If any lines were generated, set up a new current_line.
         """
 
         If any lines were generated, set up a new current_line.
         """
-
         if not self.current_line:
             if self.current_line.__class__ == type:
                 self.current_line.depth += indent
         if not self.current_line:
             if self.current_line.__class__ == type:
                 self.current_line.depth += indent
index b4dcb20c030de1403aee405c361d1599a20c8bf9..bf19a269667f7a125e9d7a568a61f58c7bdb06d3 100644 (file)
@@ -1,15 +1,10 @@
 class SimpleClassWithBlankParentheses():
     pass
 class SimpleClassWithBlankParentheses():
     pass
-
-
-class ClassWithSpaceParentheses():
+class ClassWithSpaceParentheses ( ):
     first_test_data = 90
     second_test_data = 100
     first_test_data = 90
     second_test_data = 100
-
     def test_func(self):
         return None
     def test_func(self):
         return None
-
-
 class ClassWithEmptyFunc(object):
 
     def func_with_blank_parentheses():
 class ClassWithEmptyFunc(object):
 
     def func_with_blank_parentheses():
@@ -18,16 +13,11 @@ class ClassWithEmptyFunc(object):
 
 def public_func_with_blank_parentheses():
     return None
 
 def public_func_with_blank_parentheses():
     return None
-
-
 def class_under_the_func_with_blank_parentheses():
 def class_under_the_func_with_blank_parentheses():
-
     class InsideFunc():
         pass
     class InsideFunc():
         pass
-
-
-class NormalClass():
-
+class NormalClass (
+):
     def func_for_testing(self, first, second):
         sum = first + second
         return sum
     def func_for_testing(self, first, second):
         sum = first + second
         return sum