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

Do not enforce empty lines after control flow statements
authorŁukasz Langa <lukasz@langa.pl>
Tue, 24 Apr 2018 19:40:46 +0000 (12:40 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Tue, 24 Apr 2018 19:42:46 +0000 (12:42 -0700)
Fixes #90

README.md
black.py
tests/expression.diff
tests/expression.py
tests/function.py

index 4663176726b668c45fc80ff0b12430e651af230c..a589d0d65d3e92db6c5951a0a3fa9330d4cffdd9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -218,10 +218,7 @@ bother you if you overdo it by a few km/h".
 
 *Black* avoids spurious vertical whitespace.  This is in the spirit of
 PEP 8 which says that in-function vertical whitespace should only be
-used sparingly.  One exception is control flow statements: *Black* will
-always emit an extra empty line after ``return``, ``raise``, ``break``,
-``continue``, and ``yield``.  This is to make changes in control flow
-more prominent to readers of your code.
+used sparingly.
 
 *Black* will allow single empty lines inside functions, and single and
 double empty lines on module level left by the original editors, except
@@ -528,6 +525,9 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
 * generalized star expression handling, including double stars; this
   fixes multiplication making expressions "unsafe" for trailing commas (#132)
 
+* Black no longer enforces putting empty lines behind control flow statements
+  (#90)
+
 * fixed comment indentation when a standalone comment closes a block (#16, #32)
 
 * fixed standalone comments receiving extra empty lines if immediately preceding
index 5bf466af91c5e0eb03f293621ab00346dcfc00c3..95489f3c0c990a650c8efdc4aacb43159d7f8553 100644 (file)
--- a/black.py
+++ b/black.py
@@ -1056,9 +1056,6 @@ class EmptyLineTracker:
                 newlines -= 1
             return newlines, 0
 
-        if current_line.is_flow_control:
-            return before, 1
-
         if (
             self.previous_line
             and self.previous_line.is_import
@@ -1067,13 +1064,6 @@ class EmptyLineTracker:
         ):
             return (before or 1), 0
 
-        if (
-            self.previous_line
-            and self.previous_line.is_yield
-            and (not current_line.is_yield or depth != self.previous_line.depth)
-        ):
-            return (before or 1), 0
-
         return before, 0
 
 
index da48a13a1936c62f1fde517473eebc140a6e33a7..11c135546cac7e14fed19dd971870c367a156d98 100644 (file)
  ]
  slice[0]
  slice[0:1]
-@@ -123,88 +145,122 @@
+@@ -123,88 +145,114 @@
  numpy[-(c + 1):, d]
  numpy[:, l[-2]]
  numpy[:, ::-1]
 +
  def gen():
      yield from outside_of_generator
-+
      a = (yield)
-+
  
++
  async def f():
      await some.complicated[0].call(with_args=(True or (1 is not 1)))
 -print(* [] or [1])
 -if (
 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa /
 -    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
--):
--    return True
 +print(*lambda x: x)
 +for (x,) in (1,), (2,), (3,):
 +    ...
 +    or signal.getsignal(signal.SIGINT) != signal.default_int_handler
 +):
 +    return True
-+
 +if (
 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +    | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +):
 +    return True
-+
 +if (
 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +    & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +):
 +    return True
-+
 +if (
 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +    + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +):
 +    return True
-+
 +if (
 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +    - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +):
 +    return True
-+
 +if (
 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +    * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +):
 +    return True
-+
 +if (
 +    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 +    / aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-+):
-+    return True
-+
+ ):
+     return True
  last_call()
  # standalone comment at ENDMARKER
index 2c4d8ddbd75ca3d531a89c91231fc58b8dfeb9e2..274c150fcde4aae43d18c7101d0fa5bfa72643e0 100644 (file)
@@ -409,7 +409,6 @@ mapping = {
 
 def gen():
     yield from outside_of_generator
-
     a = (yield)
 
 
@@ -438,42 +437,35 @@ if (
     or signal.getsignal(signal.SIGINT) != signal.default_int_handler
 ):
     return True
-
 if (
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
     | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 ):
     return True
-
 if (
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
     & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 ):
     return True
-
 if (
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
     + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 ):
     return True
-
 if (
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
     - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 ):
     return True
-
 if (
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
     * aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 ):
     return True
-
 if (
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
     / aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 ):
     return True
-
 last_call()
 # standalone comment at ENDMARKER
index 08f9414a7b5041452573b7c6bc6e4c2f21e3cce3..9a12bf60a9116a41649bd3d73cfee3ee3f90080e 100644 (file)
@@ -102,13 +102,11 @@ def func_no_args():
     c
     if True:
         raise RuntimeError
-
     if False:
         ...
     for i in range(10):
         print(i)
         continue
-
     exec("new-style exec", {}, {})
     return None