diff --git a/crates/ruff_formatter/src/format_element/document.rs b/crates/ruff_formatter/src/format_element/document.rs index d1de8fdd3dd9af..9ab9bd7e258331 100644 --- a/crates/ruff_formatter/src/format_element/document.rs +++ b/crates/ruff_formatter/src/format_element/document.rs @@ -451,7 +451,7 @@ impl Format> for &[FormatElement] { } StartLineSuffix(_) => { - write!(f, [text("line_suffix(")])?; // TODO(cnpryer): Would it be useful to have this info in the IR display? + write!(f, [text("line_suffix(")])?; // TODO(cnpryer) } StartVerbatim(_) => { diff --git a/crates/ruff_formatter/src/printer/mod.rs b/crates/ruff_formatter/src/printer/mod.rs index c79bc8a57926e3..9f69bd9999b2d0 100644 --- a/crates/ruff_formatter/src/printer/mod.rs +++ b/crates/ruff_formatter/src/printer/mod.rs @@ -1177,8 +1177,6 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> { } FormatElement::Tag(StartLineSuffix(line_suffix)) => { - // TODO(cnpryer): Need to understand the relationship between fits checks and prints. - // Not sure if I've ruled out any redundancy or if state should be handled better here. self.state.line_width += line_suffix.reserved_width; if self.state.line_width > self.options().print_width.into() { return Ok(Fits::No); @@ -1696,7 +1694,6 @@ two lines`, ); } - // TODO(cnpryer): Would it make sense to add a test to the printer for measured line suffix? #[test] fn line_suffix_printed_at_end() { let printed = format(&format_args![ diff --git a/crates/ruff_python_formatter/src/comments/format.rs b/crates/ruff_python_formatter/src/comments/format.rs index ce40fe8ba05290..caaca80d10d92b 100644 --- a/crates/ruff_python_formatter/src/comments/format.rs +++ b/crates/ruff_python_formatter/src/comments/format.rs @@ -156,24 +156,12 @@ impl Format> for FormatTrailingComments<'_> { empty_lines(lines_before_comment), format_comment(trailing) ], - 0 + 0 // Own-line comments never need their width measured during formatting, so it's okay to avoid the computation here. ), expand_parent() ] )?; } else { - // TODO(cnpryer): Reserved width should be used when breaking is expected. Breaking may not be - // expected when a trailing end of line comment is not at the end of a collapsed node. - // ```python - // def fn(): - // return np.divide( - // view.variance, - // view.sum_of_weights, - // out=np.full(view.sum_of_weights.shape, np.nan), - // where=view.sum_of_weights**2 > view.sum_of_weights_squared, # This shouldn't force a break - // ) - // ``` - // // ``` // A trailing comment at the end of a line has a reserved width to consider during line measurement. // ```python @@ -285,7 +273,10 @@ impl Format> for FormatDanglingOpenParenthesisComments<'_> { write!( f, [ - line_suffix(&format_args!(space(), space(), format_comment(comment)), 0), + line_suffix( + &format_args!(space(), space(), format_comment(comment)), + comment.range().len().into() // This is safe since we expect the comment to be end of line + ), expand_parent() ] )?;