Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/ruff_formatter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,8 @@ where
Context: FormatContext,
{
let mut state = FormatState::new(context);
let mut buffer = VecBuffer::with_capacity(arguments.items().len(), &mut state);
let mut buffer =
VecBuffer::with_capacity(state.context().source_code().as_str().len(), &mut state);

buffer.write_fmt(arguments)?;

Expand Down
5 changes: 5 additions & 0 deletions crates/ruff_python_formatter/src/expression/expr_compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ impl FormatNodeRule<ExprCompare> for FormatExprCompare {

in_parentheses_only_group(&inner).fmt(f)
}

fn fmt_dangling_comments(&self, _node: &ExprCompare, _f: &mut PyFormatter) -> FormatResult<()> {
// Node can not have dangling comments
Ok(())
}
}

impl NeedsParentheses for ExprCompare {
Expand Down
5 changes: 5 additions & 0 deletions crates/ruff_python_formatter/src/expression/expr_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ impl FormatNodeRule<ExprName> for FormatExprName {

write!(f, [source_text_slice(*range, ContainsNewlines::No)])
}

fn fmt_dangling_comments(&self, _node: &ExprName, _f: &mut PyFormatter) -> FormatResult<()> {
// Node cannot have dangling comments
Ok(())
}
}

impl NeedsParentheses for ExprName {
Expand Down