-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.Issues with the preview and unstable style. Add the name of the responsible feature in the title.T: bugSomething isn't workingSomething isn't working
Description
Using macOS:
$ black --version
black, 23.10.1 (compiled: yes)
Python (CPython) 3.10.12Take this code:
"""This is a test case, note blank lines next."""
def go():
print("Do stuff!")
go()And run this:
$ black --diff blanks.py
--- blanks.py 2023-11-06 18:04:21.775563+00:00
+++ blanks.py 2023-11-06 18:04:37.405865+00:00
@@ -1,4 +1,8 @@
"""This is a test case, note blank lines next."""
+
+
def go():
print("Do stuff!")
+
+
go()
would reformat blanks.py
All done! ✨ 🍰 ✨
1 file would be reformatted.
Note current default behavior is to put two blank lines between the module docstring and following function. This is as expected, quoting https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html
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 and classes.
Now in preview mode:
$ black --diff blanks.py --preview
--- blanks.py 2023-11-06 18:04:21.775563+00:00
+++ blanks.py 2023-11-06 18:04:42.146632+00:00
@@ -1,4 +1,7 @@
"""This is a test case, note blank lines next."""
+
def go():
print("Do stuff!")
+
+
go()
This now only has one line between the module docstring and following function. This seems like an unintended consequence of #1872.
Metadata
Metadata
Assignees
Labels
C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.Issues with the preview and unstable style. Add the name of the responsible feature in the title.T: bugSomething isn't workingSomething isn't working