Skip to content

Commit

Permalink
Add broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Oct 13, 2023
1 parent 972e9ec commit 35c6120
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
###
# Blank lines around functions
###
import sys

x = 1

Expand Down Expand Up @@ -209,6 +210,29 @@ def inner():
pass
print("below nested functions")


class Path:
if sys.version_info >= (3, 11):
def joinpath(self): ...

# The .open method comes from pathlib.pyi and should be kept in sync.
@overload
def open(self): ...




def fakehttp():

class FakeHTTPConnection:
if mock_close:
def close(self):
pass
FakeHTTPConnection.fakedata = fakedata




if True:
def nested_trailing_function():
pass
3 changes: 2 additions & 1 deletion crates/ruff_python_formatter/src/statement/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ impl FormatRule<Suite, PyFormatContext<'_>> for FormatSuite {
.map(|token| token.kind);
if !matches!(
next_token_kind,
None | Some(SimpleTokenKind::Def | SimpleTokenKind::Class)
// At is for decorators
None | Some(SimpleTokenKind::Def | SimpleTokenKind::Class | SimpleTokenKind::At)
) {
empty_line().fmt(f)?;
}
Expand Down
25 changes: 25 additions & 0 deletions crates/ruff_python_formatter/tests/snapshots/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/newlines.p
###
# Blank lines around functions
###
import sys
x = 1
Expand Down Expand Up @@ -215,6 +216,16 @@ def outer():
pass
print("below nested functions")
class Path:
if sys.version_info >= (3, 11):
def joinpath(self): ...
# The .open method comes from pathlib.pyi and should be kept in sync.
@overload
def open(self): ...
if True:
def nested_trailing_function():
pass```
Expand All @@ -224,6 +235,7 @@ if True:
###
# Blank lines around functions
###
import sys
x = 1
Expand Down Expand Up @@ -454,6 +466,19 @@ def outer():
print("below nested functions")
class Path:
if sys.version_info >= (3, 11):
def joinpath(self):
...
# The .open method comes from pathlib.pyi and should be kept in sync.
@overload
def open(self):
...
if True:
def nested_trailing_function():
Expand Down

0 comments on commit 35c6120

Please sign in to comment.