Loading README.md +6 −5 Changes for README.md: 6 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -230,11 +230,9 @@ are always reformatted to fit minimal space, this whitespace is lost. It will also insert proper spacing before and after function definitions. It's one line before and after inner functions and two lines before and after module-level functions. *Black* will put those empty lines also between the function definition and any standalone comments that immediately precede the given function. If you want to comment on the entire function, use a docstring or put a leading comment in the function body. after module-level functions. *Black* will not put empty lines between function/class definitions and standalone comments that immediately precede the given function/class. ### Trailing commas Loading Loading @@ -532,6 +530,9 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md). * fixed comment indentation when a standalone comment closes a block (#16, #32) * fixed standalone comments receiving extra empty lines if immediately preceding a class, def, or decorator (#56, #154) * fixed `--diff` not showing entire path (#130) * fixed parsing of complex expressions after star and double stars in Loading black.py +6 −4 Changes for black.py: 6 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -1040,12 +1040,14 @@ def _maybe_empty_lines(self, current_line: Line) -> Tuple[int, int]: # 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 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 Loading tests/comments2.py +0 −2 Changes for tests/comments2.py: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -161,8 +161,6 @@ def inline_comments_in_brackets_ruin_everything(): # add_compiler(compilers[(7.1, 64)]) # Comment before function. def inline_comments_in_brackets_ruin_everything(): if typedargslist: parameters.children = [ Loading tests/comments5.py +40 −0 Changes for tests/comments5.py: 40 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -27,5 +27,45 @@ except OSError: print("problems") import sys # leading function comment def wat(): ... # trailing function comment # SECTION COMMENT # leading 1 @deco1 # leading 2 @deco2(with_args=True) # leading 3 @deco3 def decorated1(): ... # leading 1 @deco1 # leading 2 @deco2(with_args=True) # leading function comment def decorated1(): ... # Note: crappy but inevitable. The current design of EmptyLineTracker doesn't # allow this to work correctly. The user will have to split those lines by # hand. some_instruction # This comment should be split from `some_instruction` by two lines but isn't. def g(): ... if __name__ == "__main__": main() tests/comments6.pydeleted 100644 → 0 +0 −8 Changes for tests/comments6.py: 0 added lines, 8 removed lines. Original line number Diff line number Diff line @property # TODO: X @property # TODO: Y # TODO: Z @property def foo(): pass Loading
README.md +6 −5 Changes for README.md: 6 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -230,11 +230,9 @@ are always reformatted to fit minimal space, this whitespace is lost. It will also insert proper spacing before and after function definitions. It's one line before and after inner functions and two lines before and after module-level functions. *Black* will put those empty lines also between the function definition and any standalone comments that immediately precede the given function. If you want to comment on the entire function, use a docstring or put a leading comment in the function body. after module-level functions. *Black* will not put empty lines between function/class definitions and standalone comments that immediately precede the given function/class. ### Trailing commas Loading Loading @@ -532,6 +530,9 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md). * fixed comment indentation when a standalone comment closes a block (#16, #32) * fixed standalone comments receiving extra empty lines if immediately preceding a class, def, or decorator (#56, #154) * fixed `--diff` not showing entire path (#130) * fixed parsing of complex expressions after star and double stars in Loading
black.py +6 −4 Changes for black.py: 6 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -1040,12 +1040,14 @@ def _maybe_empty_lines(self, current_line: Line) -> Tuple[int, int]: # 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 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 Loading
tests/comments2.py +0 −2 Changes for tests/comments2.py: 0 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -161,8 +161,6 @@ def inline_comments_in_brackets_ruin_everything(): # add_compiler(compilers[(7.1, 64)]) # Comment before function. def inline_comments_in_brackets_ruin_everything(): if typedargslist: parameters.children = [ Loading
tests/comments5.py +40 −0 Changes for tests/comments5.py: 40 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -27,5 +27,45 @@ except OSError: print("problems") import sys # leading function comment def wat(): ... # trailing function comment # SECTION COMMENT # leading 1 @deco1 # leading 2 @deco2(with_args=True) # leading 3 @deco3 def decorated1(): ... # leading 1 @deco1 # leading 2 @deco2(with_args=True) # leading function comment def decorated1(): ... # Note: crappy but inevitable. The current design of EmptyLineTracker doesn't # allow this to work correctly. The user will have to split those lines by # hand. some_instruction # This comment should be split from `some_instruction` by two lines but isn't. def g(): ... if __name__ == "__main__": main()
tests/comments6.pydeleted 100644 → 0 +0 −8 Changes for tests/comments6.py: 0 added lines, 8 removed lines. Original line number Diff line number Diff line @property # TODO: X @property # TODO: Y # TODO: Z @property def foo(): pass