-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix instable formatting for trailing subscribt end-of-line comment #10492
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
slice
is not anExprSlice
and 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
slice
is anExprSlice
.Fixes #10355
Versioning
Shipping this as part of a patch release is fine because:
Test Plan
Added tests