Format StmtExpr (#4788)

This commit is contained in:
Micha Reiser 2023-06-02 14:52:38 +02:00 committed by GitHub
parent 4cd4b37e74
commit a401989b7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 77 additions and 19 deletions

View file

@ -1,5 +1,5 @@
use crate::{verbatim_text, FormatNodeRule, PyFormatter};
use ruff_formatter::{write, Buffer, FormatResult};
use crate::prelude::*;
use crate::FormatNodeRule;
use rustpython_parser::ast::StmtExpr;
#[derive(Default)]
@ -7,6 +7,8 @@ pub struct FormatStmtExpr;
impl FormatNodeRule<StmtExpr> for FormatStmtExpr {
fn fmt_fields(&self, item: &StmtExpr, f: &mut PyFormatter) -> FormatResult<()> {
write!(f, [verbatim_text(item.range)])
let StmtExpr { value, .. } = item;
value.format().fmt(f)
}
}