Don't put four empty lines between top-level functions split by a comment

This commit is contained in:
Łukasz Langa 2018-03-16 22:14:43 -07:00
parent 7ad9445caf
commit b9c06a0d23
2 changed files with 7 additions and 0 deletions

View File

@ -269,6 +269,9 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
* remove a trailing comma if there is a single argument to a call * remove a trailing comma if there is a single argument to a call
* if top level functions were separated by a comment, don't put four
empty lines after the upper function
* fixed missing space in numpy-style array indexing (#33) * fixed missing space in numpy-style array indexing (#33)
* fixed spurious space after star-based unary expressions (#31) * fixed spurious space after star-based unary expressions (#31)

View File

@ -628,6 +628,10 @@ def maybe_empty_lines(self, current_line: Line) -> Tuple[int, int]:
(two on module-level), as well as providing an extra empty line after flow (two on module-level), as well as providing an extra empty line after flow
control keywords to make them more prominent. control keywords to make them more prominent.
""" """
if current_line.is_comment:
# Don't count standalone comments towards previous empty lines.
return 0, 0
before, after = self._maybe_empty_lines(current_line) before, after = self._maybe_empty_lines(current_line)
self.previous_after = after self.previous_after = after
self.previous_line = current_line self.previous_line = current_line