Skip to content

Commit

Permalink
Update snapshot
Browse files Browse the repository at this point in the history
Set output to target
  • Loading branch information
cnpryer committed Jun 24, 2023
1 parent 3466a0b commit d103b07
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ del (
# Done deleting
# Delete something
del x, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, b, c, d # Delete these
del (
x,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
b,
c,
d
) # Delete these
# Ready to delete
# Delete something
Expand Down
20 changes: 6 additions & 14 deletions crates/ruff_python_formatter/src/statement/stmt_delete.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::expression::parentheses::Parenthesize;
use crate::prelude::PyFormatContext;
use crate::{AsFormat, FormatNodeRule, PyFormatter};
use crate::{FormatNodeRule, FormattedIterExt, PyFormatter};
use ruff_formatter::prelude::{
format_args, format_with, group, soft_line_break_or_space, space, text, Formatter,
format_args, group, soft_line_break_or_space, space, text, Formatter,
};
use ruff_formatter::{write, Buffer, Format, FormatResult};
use rustpython_parser::ast::{Expr, StmtDelete};
Expand All @@ -13,7 +12,7 @@ pub struct FormatStmtDelete;
impl FormatNodeRule<StmtDelete> for FormatStmtDelete {
fn fmt_fields(&self, item: &StmtDelete, f: &mut PyFormatter) -> FormatResult<()> {
let StmtDelete { range: _, targets } = item;
write!(f, [text("del"), space(), DeleteList::new(targets)])
write!(f, [text("del"), space(), group(&DeleteList::new(targets))])
}
}

Expand All @@ -31,15 +30,8 @@ impl<'a> DeleteList<'a> {

impl Format<PyFormatContext<'_>> for DeleteList<'_> {
fn fmt(&self, f: &mut Formatter<PyFormatContext<'_>>) -> FormatResult<()> {
let separator =
format_with(|f| group(&format_args![text(","), soft_line_break_or_space(),]).fmt(f));
let mut join = f.join_with(separator);

for element in self.delete_list {
join.entry(&format_with(|f| {
write!(f, [element.format().with_options(Parenthesize::IfBreaks)])
}));
}
join.finish()
f.join_with(&format_args!(text(","), soft_line_break_or_space()))
.entries(self.delete_list.iter().formatted())
.finish()
}
}

0 comments on commit d103b07

Please sign in to comment.