-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix instable formatting for trailing subscribt end-of-line comment (#…
…10492) ## Summary This PR fixes an instability where formatting a subscribt where the `slice` is not an `ExprSlice` 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 an `ExprSlice`. Fixes #10355 ## Versioning Shipping this as part of a patch release is fine because: * It fixes a stability issue * It doesn't impact already formatted code because Ruff would already have moved to the comment to the end of the line (instead of preserving it) ## Test Plan Added tests
- Loading branch information
1 parent
7caf0d0
commit 954a48b
Showing
3 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters