Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update empty line documentation #4239

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 15 additions & 24 deletions docs/the_black_code_style/current_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading