Allow empty lines at beginning of blocks (again)
This commit is contained in:
parent
a8062983cd
commit
18e711f7b4
@ -13,9 +13,10 @@
|
|||||||
### Preview style
|
### Preview style
|
||||||
|
|
||||||
- Standalone form feed characters at the module level are no longer removed (#4021)
|
- Standalone form feed characters at the module level are no longer removed (#4021)
|
||||||
|
|
||||||
- Additional cases of immediately nested tuples, lists, and dictionaries are now
|
- Additional cases of immediately nested tuples, lists, and dictionaries are now
|
||||||
indented less (#4012)
|
indented less (#4012)
|
||||||
|
- Allow empty lines at the beginning of all blocks, except immediately before a
|
||||||
|
docstring (#4060)
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
|
@ -685,17 +685,13 @@ def _maybe_empty_lines(self, current_line: Line) -> Tuple[int, int]:
|
|||||||
return before, 1
|
return before, 1
|
||||||
|
|
||||||
is_empty_first_line_ok = (
|
is_empty_first_line_ok = (
|
||||||
Preview.allow_empty_first_line_before_new_block_or_comment
|
Preview.allow_empty_first_line_in_block
|
||||||
in current_line.mode
|
in current_line.mode
|
||||||
and (
|
and (
|
||||||
# If it's a standalone comment
|
not is_docstring(current_line.leaves[0])
|
||||||
current_line.leaves[0].type == STANDALONE_COMMENT
|
|
||||||
# If it opens a new block
|
|
||||||
or current_line.opens_block
|
|
||||||
# If it's a triple quote comment (but not at the start of a funcdef)
|
# If it's a triple quote comment (but not at the start of a funcdef)
|
||||||
or (
|
or (
|
||||||
is_docstring(current_line.leaves[0])
|
self.previous_line
|
||||||
and self.previous_line
|
|
||||||
and self.previous_line.leaves[0]
|
and self.previous_line.leaves[0]
|
||||||
and self.previous_line.leaves[0].parent
|
and self.previous_line.leaves[0].parent
|
||||||
and not is_funcdef(self.previous_line.leaves[0].parent)
|
and not is_funcdef(self.previous_line.leaves[0].parent)
|
||||||
|
@ -191,7 +191,7 @@ class Preview(Enum):
|
|||||||
accept_raw_docstrings = auto()
|
accept_raw_docstrings = auto()
|
||||||
fix_power_op_line_length = auto()
|
fix_power_op_line_length = auto()
|
||||||
hug_parens_with_braces_and_square_brackets = auto()
|
hug_parens_with_braces_and_square_brackets = auto()
|
||||||
allow_empty_first_line_before_new_block_or_comment = auto()
|
allow_empty_first_line_in_block = auto()
|
||||||
single_line_format_skip_with_multiple_comments = auto()
|
single_line_format_skip_with_multiple_comments = auto()
|
||||||
long_case_block_line_splitting = auto()
|
long_case_block_line_splitting = auto()
|
||||||
allow_form_feeds = auto()
|
allow_form_feeds = auto()
|
||||||
|
@ -51,6 +51,10 @@ def baz():
|
|||||||
if x:
|
if x:
|
||||||
a = 123
|
a = 123
|
||||||
|
|
||||||
|
def quux():
|
||||||
|
|
||||||
|
new_line = here
|
||||||
|
|
||||||
# output
|
# output
|
||||||
|
|
||||||
def foo():
|
def foo():
|
||||||
@ -104,3 +108,8 @@ def baz():
|
|||||||
# OK
|
# OK
|
||||||
if x:
|
if x:
|
||||||
a = 123
|
a = 123
|
||||||
|
|
||||||
|
|
||||||
|
def quux():
|
||||||
|
|
||||||
|
new_line = here
|
@ -198,6 +198,7 @@ def foo():
|
|||||||
|
|
||||||
# form feeds are prohibited inside blocks, or on a line with nonwhitespace
|
# form feeds are prohibited inside blocks, or on a line with nonwhitespace
|
||||||
def bar(a=1, b: bool = False):
|
def bar(a=1, b: bool = False):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user