-
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.
Preserve trailing semicolons when using
fmt: off
(#8275)
- Loading branch information
1 parent
2c84f91
commit 3ccca33
Showing
3 changed files
with
108 additions
and
8 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/trailing_semicolon.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,27 @@ | ||
def f(): | ||
# fmt: off | ||
a = 10 | ||
|
||
if True: | ||
with_semicolon = 10 \ | ||
; | ||
|
||
formatted = true; | ||
|
||
|
||
def f(): | ||
# fmt: off | ||
|
||
if True: | ||
with_semicolon = 20 \ | ||
; # comment | ||
|
||
|
||
# fmt: off | ||
statement = 0 \ | ||
; | ||
# fmt: on | ||
a = 10 | ||
|
||
# fmt: off | ||
last_statement_with_semi ; |
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
69 changes: 69 additions & 0 deletions
69
crates/ruff_python_formatter/tests/snapshots/format@fmt_on_off__trailing_semicolon.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,69 @@ | ||
--- | ||
source: crates/ruff_python_formatter/tests/fixtures.rs | ||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/fmt_on_off/trailing_semicolon.py | ||
--- | ||
## Input | ||
```py | ||
def f(): | ||
# fmt: off | ||
a = 10 | ||
if True: | ||
with_semicolon = 10 \ | ||
; | ||
formatted = true; | ||
def f(): | ||
# fmt: off | ||
if True: | ||
with_semicolon = 20 \ | ||
; # comment | ||
# fmt: off | ||
statement = 0 \ | ||
; | ||
# fmt: on | ||
a = 10 | ||
# fmt: off | ||
last_statement_with_semi ; | ||
``` | ||
|
||
## Output | ||
```py | ||
def f(): | ||
# fmt: off | ||
a = 10 | ||
if True: | ||
with_semicolon = 10 \ | ||
; | ||
formatted = true | ||
def f(): | ||
# fmt: off | ||
if True: | ||
with_semicolon = 20 \ | ||
; # comment | ||
# fmt: off | ||
statement = 0 \ | ||
; | ||
# fmt: on | ||
a = 10 | ||
# fmt: off | ||
last_statement_with_semi ; | ||
``` | ||
|
||
|
||
|