From 683105527d5648d36983ad12efd905fcf664d8c1 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Sun, 18 Feb 2024 14:27:40 -0800 Subject: [PATCH] Update empty line documentation Reflects status quo following #4043 Fixes #4238 --- docs/the_black_code_style/current_style.md | 39 +++++++++------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/docs/the_black_code_style/current_style.md b/docs/the_black_code_style/current_style.md index 586c79074af..68cd6175e3e 100644 --- a/docs/the_black_code_style/current_style.md +++ b/docs/the_black_code_style/current_style.md @@ -166,44 +166,35 @@ that in-function vertical whitespace should only be 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 when they're within parenthesized expressions. Since such expressions are always reformatted to fit minimal -space, this whitespace is lost. The other exception is that it will remove any empty -lines immediately following a statement that introduces a new indentation level. +space, this whitespace is lost. ```python # in: -def foo(): +def function( + some_argument: int, - print("All the newlines above me should be deleted!") + other_argument: int = 5, +) -> EmptyLineInParenWillBeDeleted: -if condition: - print("No newline above me!") - - print("There is a newline above me, and that's OK!") - - -class Point: - - x: int - y: int + print("One empty line above me will be kept!") +def this_is_okay_too(): + print("No empty line here") # out: -def foo(): - print("All the newlines above me should be deleted!") - - -if condition: - print("No newline above me!") +def function( + some_argument: int, + other_argument: int = 5, +) -> EmptyLineInParenWillBeDeleted: - print("There is a newline above me, and that's OK!") + print("One empty line above me will be kept!") -class Point: - x: int - y: int +def this_is_okay_too(): + print("No empty line here") ``` It will also insert proper spacing before and after function definitions. It's one line