Skip to content

Commit

Permalink
Implement StmtPass (#4959)
Browse files Browse the repository at this point in the history
This implements StmtPass as `pass`.

The snapshot diff is small because pass mainly occurs in bodies and function (#4951) and if/for bodies.
  • Loading branch information
konstin committed Jun 13, 2023
1 parent 8312801 commit b002d19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ while (
## Output
```py
while 34: # trailing test comment
NOT_YET_IMPLEMENTED_StmtPass # trailing last statement comment
pass # trailing last statement comment
# trailing while body comment
# leading else comment
else: # trailing else comment
NOT_YET_IMPLEMENTED_StmtPass
pass
# trailing else body comment
while (
aVeryLongConditionThatSpillsOverToTheNextLineBecauseItIsExtremelyLongAndGoesOnAndOnAndOnAndOnAndOnAndOnAndOnAndOnAndOn
): # trailing comment
NOT_YET_IMPLEMENTED_StmtPass
pass
else:
...
Expand Down
9 changes: 5 additions & 4 deletions crates/ruff_python_formatter/src/statement/stmt_pass.rs
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::StmtPass;

#[derive(Default)]
pub struct FormatStmtPass;

impl FormatNodeRule<StmtPass> for FormatStmtPass {
fn fmt_fields(&self, item: &StmtPass, f: &mut PyFormatter) -> FormatResult<()> {
write!(f, [not_yet_implemented(item)])
fn fmt_fields(&self, _item: &StmtPass, f: &mut PyFormatter) -> FormatResult<()> {
text("pass").fmt(f)
}
}

0 comments on commit b002d19

Please sign in to comment.