diff --git a/crates/ruff_python_formatter/src/builders.rs b/crates/ruff_python_formatter/src/builders.rs index 5c82bd15f717f..847df4d3c5e13 100644 --- a/crates/ruff_python_formatter/src/builders.rs +++ b/crates/ruff_python_formatter/src/builders.rs @@ -70,7 +70,7 @@ impl<'fmt, 'ast, 'buf> JoinNodesBuilder<'fmt, 'ast, 'buf> { }; match node_level { - NodeLevel::TopLevel => match dbg!(count_lines(last_end)) { + NodeLevel::TopLevel => match count_lines(last_end) { 0 | 1 => hard_line_break().fmt(self.fmt), 2 => empty_line().fmt(self.fmt), _ => write!(self.fmt, [empty_line(), empty_line()]), diff --git a/crates/ruff_python_formatter/src/lib.rs b/crates/ruff_python_formatter/src/lib.rs index 2c3eb49b37dca..99d735de871a2 100644 --- a/crates/ruff_python_formatter/src/lib.rs +++ b/crates/ruff_python_formatter/src/lib.rs @@ -355,11 +355,12 @@ Formatted twice: #[ignore] #[test] fn quick_test() { - let src = r#" -while True: - if something.changed: - do.stuff() # trailing comment -other + let src = r#"AAAAAAAAAAAAA = AAAAAAAAAAAAA # type: ignore + +call_to_some_function_asdf( + foo, + [AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, BBBBBBBBBBBB], # type: ignore +) "#; // Tokenize once let mut tokens = Vec::new();