-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Summary format `StmtBreak` trying to learn how to help out with the formatter. starting simple ## Test Plan new snapshot test
- Loading branch information
1 parent
be107da
commit 4b9b682
Showing
3 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/break.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,5 @@ | ||
# leading comment | ||
while True: # block comment | ||
# inside comment | ||
break # break comment | ||
# post comment |
25 changes: 25 additions & 0 deletions
25
...formatter/src/snapshots/ruff_python_formatter__tests__ruff_test__statement__break_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,25 @@ | ||
--- | ||
source: crates/ruff_python_formatter/src/lib.rs | ||
expression: snapshot | ||
--- | ||
## Input | ||
```py | ||
# leading comment | ||
while True: # block comment | ||
# inside comment | ||
break # break comment | ||
# post comment | ||
``` | ||
|
||
|
||
|
||
## Output | ||
```py | ||
# leading comment | ||
while True: # block comment | ||
# inside comment | ||
break # break comment | ||
# post comment | ||
``` | ||
|
||
|
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 |
---|---|---|
@@ -1,12 +1,13 @@ | ||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter}; | ||
use ruff_formatter::{write, Buffer, FormatResult}; | ||
use crate::{FormatNodeRule, PyFormatter}; | ||
use ruff_formatter::prelude::text; | ||
use ruff_formatter::{Format, FormatResult}; | ||
use rustpython_parser::ast::StmtBreak; | ||
|
||
#[derive(Default)] | ||
pub struct FormatStmtBreak; | ||
|
||
impl FormatNodeRule<StmtBreak> for FormatStmtBreak { | ||
fn fmt_fields(&self, item: &StmtBreak, f: &mut PyFormatter) -> FormatResult<()> { | ||
write!(f, [not_yet_implemented(item)]) | ||
fn fmt_fields(&self, _item: &StmtBreak, f: &mut PyFormatter) -> FormatResult<()> { | ||
text("break").fmt(f) | ||
} | ||
} |