Avoid hard line break after dangling open-parenthesis comments (#6380)

## Summary

Given:

```python
[  # comment
    first,
    second,
    third
]  # another comment
```

We were adding a hard line break as part of the formatting of `#
comment`, which led to the following formatting:

```python
[first, second, third]  # comment
  # another comment
```

Closes https://github.com/astral-sh/ruff/issues/6367.
This commit is contained in:
Charlie Marsh 2023-08-07 10:15:32 -04:00 committed by GitHub
parent 63692b3798
commit b763973357
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 82 additions and 18 deletions

View file

@ -95,8 +95,9 @@ use std::rc::Rc;
use ruff_python_ast::{Mod, Ranged};
pub(crate) use format::{
dangling_comments, dangling_node_comments, leading_alternate_branch_comments, leading_comments,
leading_node_comments, trailing_comments, trailing_node_comments,
dangling_comments, dangling_node_comments, dangling_open_parenthesis_comments,
leading_alternate_branch_comments, leading_comments, leading_node_comments, trailing_comments,
trailing_node_comments,
};
use ruff_formatter::{SourceCode, SourceCodeSlice};
use ruff_python_ast::node::AnyNodeRef;