Skip to content

Commit

Permalink
Format ModExpression (#5689)
Browse files Browse the repository at this point in the history
## Summary

We don't use `ModExpression` anywhere but it's part of the AST, removes
one `not_implemented_yet` and is a trivial 2-liner, so i implemented
formatting for `ModExpression`.

## Test Plan

None, this kind of node does not occur in file input. Otherwise all the
tests for expressions
  • Loading branch information
konstin committed Jul 19, 2023
1 parent 26eb080 commit 69557cf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/ruff_python_formatter/src/module/mod_expression.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::{AsFormat, FormatNodeRule, PyFormatter};
use ruff_formatter::{Format, FormatResult};
use rustpython_parser::ast::ModExpression;

#[derive(Default)]
pub struct FormatModExpression;

impl FormatNodeRule<ModExpression> for FormatModExpression {
fn fmt_fields(&self, item: &ModExpression, f: &mut PyFormatter) -> FormatResult<()> {
write!(f, [not_yet_implemented(item)])
let ModExpression { body, range: _ } = item;
body.format().fmt(f)
}
}

0 comments on commit 69557cf

Please sign in to comment.