-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorect placement of trailing stub function comments (#11632)
- Loading branch information
1 parent
889667a
commit 9b6d2ce
Showing
6 changed files
with
142 additions
and
44 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...thon_formatter/resources/test/fixtures/ruff/statement/stub_functions_trailing_comments.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Regression tests for https://github.com/astral-sh/ruff/issues/11569 | ||
|
||
|
||
# comment 1 | ||
def foo(self) -> None: ... | ||
def bar(self) -> None: ... | ||
# comment 2 | ||
|
||
# comment 3 | ||
def baz(self) -> None: | ||
return None | ||
# comment 4 | ||
|
||
|
||
def foo(self) -> None: ... | ||
# comment 5 | ||
|
||
def baz(self) -> None: | ||
return None | ||
|
||
|
||
def foo(self) -> None: | ||
... # comment 5 | ||
def baz(self) -> None: | ||
return None | ||
|
||
def foo(self) -> None: ... | ||
# comment 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...thon_formatter/tests/snapshots/format@statement__stub_functions_trailing_comments.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
source: crates/ruff_python_formatter/tests/fixtures.rs | ||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/stub_functions_trailing_comments.py | ||
--- | ||
## Input | ||
```python | ||
# Regression tests for https://github.com/astral-sh/ruff/issues/11569 | ||
# comment 1 | ||
def foo(self) -> None: ... | ||
def bar(self) -> None: ... | ||
# comment 2 | ||
# comment 3 | ||
def baz(self) -> None: | ||
return None | ||
# comment 4 | ||
def foo(self) -> None: ... | ||
# comment 5 | ||
def baz(self) -> None: | ||
return None | ||
def foo(self) -> None: | ||
... # comment 5 | ||
def baz(self) -> None: | ||
return None | ||
def foo(self) -> None: ... | ||
# comment 5 | ||
``` | ||
|
||
## Output | ||
```python | ||
# Regression tests for https://github.com/astral-sh/ruff/issues/11569 | ||
# comment 1 | ||
def foo(self) -> None: ... | ||
def bar(self) -> None: ... | ||
# comment 2 | ||
# comment 3 | ||
def baz(self) -> None: | ||
return None | ||
# comment 4 | ||
def foo(self) -> None: ... | ||
# comment 5 | ||
def baz(self) -> None: | ||
return None | ||
def foo(self) -> None: ... # comment 5 | ||
def baz(self) -> None: | ||
return None | ||
def foo(self) -> None: ... | ||
# comment 5 | ||
``` |