Files
ruff/crates/ruff_python_formatter/src/statement
Micha Reiser a56d42f183 Refactor with statement formatting to have explicit layouts (#10296)
## Summary

This PR refactors the with item formatting to use more explicit layouts
to make it easier to understand the different formatting cases.

The benefit of the explicit layout is that it makes it easier to reasons
about layout transition between format runs. For example, today it's
possible that `SingleWithTarget` or `ParenthesizeIfExpands` add
parentheses around the with items for `with aaaaaaaaaa + bbbbbbbbbbbb:
pass`, resulting in `with (aaaaaaaaaa + bbbbbbbbbbbb): pass`. The
problem with this is that the next formatting pass uses the
`SingleParenthesizedContextExpression` layout that uses
`maybe_parenthesize_expression` which is different from
`parenthesize_if_expands(&expr)` or `optional_parentheses(&expr)`.

## Test Plan

`cargo test`

I ran the ecosystem checks locally and there are no changes.
2024-03-08 18:40:39 -05:00
..
2024-02-29 09:30:54 +01:00
2024-02-29 09:30:54 +01:00
2024-02-29 09:30:54 +01:00
2024-02-29 09:30:54 +01:00
2023-09-02 10:05:47 +02:00
2024-01-31 11:13:37 +01:00
2023-09-02 10:05:47 +02:00
2023-09-02 10:05:47 +02:00
2024-02-29 09:30:54 +01:00
2024-02-29 09:30:54 +01:00