mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 01:51:30 +00:00
Implement StmtPass (#4959)
This implements StmtPass as `pass`. The snapshot diff is small because pass mainly occurs in bodies and function (#4951) and if/for bodies.
This commit is contained in:
parent
6bef347a8e
commit
c8442e91ce
2 changed files with 8 additions and 7 deletions
|
@ -41,14 +41,14 @@ while (
|
||||||
## Output
|
## Output
|
||||||
```py
|
```py
|
||||||
while 34: # trailing test comment
|
while 34: # trailing test comment
|
||||||
NOT_YET_IMPLEMENTED_StmtPass # trailing last statement comment
|
pass # trailing last statement comment
|
||||||
|
|
||||||
# trailing while body comment
|
# trailing while body comment
|
||||||
|
|
||||||
# leading else comment
|
# leading else comment
|
||||||
|
|
||||||
else: # trailing else comment
|
else: # trailing else comment
|
||||||
NOT_YET_IMPLEMENTED_StmtPass
|
pass
|
||||||
|
|
||||||
# trailing else body comment
|
# trailing else body comment
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ else: # trailing else comment
|
||||||
while (
|
while (
|
||||||
aVeryLongConditionThatSpillsOverToTheNextLineBecauseItIsExtremelyLongAndGoesOnAndOnAndOnAndOnAndOnAndOnAndOnAndOnAndOn
|
aVeryLongConditionThatSpillsOverToTheNextLineBecauseItIsExtremelyLongAndGoesOnAndOnAndOnAndOnAndOnAndOnAndOnAndOnAndOn
|
||||||
): # trailing comment
|
): # trailing comment
|
||||||
NOT_YET_IMPLEMENTED_StmtPass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
...
|
...
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
use crate::{FormatNodeRule, PyFormatter};
|
||||||
use ruff_formatter::{write, Buffer, FormatResult};
|
use ruff_formatter::prelude::text;
|
||||||
|
use ruff_formatter::{Format, FormatResult};
|
||||||
use rustpython_parser::ast::StmtPass;
|
use rustpython_parser::ast::StmtPass;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct FormatStmtPass;
|
pub struct FormatStmtPass;
|
||||||
|
|
||||||
impl FormatNodeRule<StmtPass> for FormatStmtPass {
|
impl FormatNodeRule<StmtPass> for FormatStmtPass {
|
||||||
fn fmt_fields(&self, item: &StmtPass, f: &mut PyFormatter) -> FormatResult<()> {
|
fn fmt_fields(&self, _item: &StmtPass, f: &mut PyFormatter) -> FormatResult<()> {
|
||||||
write!(f, [not_yet_implemented(item)])
|
text("pass").fmt(f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue