Fix instable formatting for trailing subscribt end-of-line comment#10492
Conversation
|
|
Hmm, I was wrong. I need to look into the ecosystem changes. Never mind. These are unformatted projects and the ecosystem changes show that the comment position is now preserved |
## Summary This is a follow up on #10492 I incorrectly assumed that `subscript.value.end()` always points past the value. However, this isn't the case for parenthesized values where the end "ends" before the parentheses. ## Test Plan I added new tests for the parenthesized case.
Summary
This PR fixes an instability where formatting a subscribt
where the
sliceis not anExprSliceand it has a trailing end-of-line comment after its opening[required two formatting passes to be stable.The fix is to associate the trailing end-of-line comment as dangling comment on
[to preserve its position, similar to how Ruff does it for other parenthesized expressions.This also matches how trailing end-of-line subscript comments are handled when the
sliceis anExprSlice.Fixes #10355
Versioning
Shipping this as part of a patch release is fine because:
Test Plan
Added tests