mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 18:11:08 +00:00
Call chain formatting in fluent style (#6151)
Implement fluent style/call chains. See the `call_chains.py` formatting for examples. This isn't fully like black because in `raise A from B` they allow `A` breaking can influence the formatting of `B` even if it is already multiline. Similarity index: | project | main | PR | |--------------|-------|-------| | build | ??? | 0.753 | | django | 0.991 | 0.998 | | transformers | 0.993 | 0.994 | | typeshed | 0.723 | 0.723 | | warehouse | 0.978 | 0.994 | | zulip | 0.992 | 0.994 | Call chain formatting is affected by https://github.com/astral-sh/ruff/issues/627, but i'm cutting scope here. Closes #5343 **Test Plan**: * Added a dedicated call chains test file * The ecosystem checks found some bugs * I manually check django and zulip formatting --------- Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
35bdbe43a8
commit
99baad12d8
16 changed files with 917 additions and 517 deletions
|
@ -1016,7 +1016,7 @@ fn handle_attribute_comment<'a>(
|
|||
.contains(comment.slice().start())
|
||||
);
|
||||
if comment.line_position().is_end_of_line() {
|
||||
// Attach to node with b
|
||||
// Attach as trailing comment to a. The specific placement is only relevant for fluent style
|
||||
// ```python
|
||||
// x322 = (
|
||||
// a
|
||||
|
@ -1024,7 +1024,7 @@ fn handle_attribute_comment<'a>(
|
|||
// b
|
||||
// )
|
||||
// ```
|
||||
CommentPlacement::trailing(comment.enclosing_node(), comment)
|
||||
CommentPlacement::trailing(attribute.value.as_ref(), comment)
|
||||
} else {
|
||||
CommentPlacement::dangling(attribute, comment)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue