mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:56 +00:00
Format all attribute dot comments manually (#6825)
## Summary This PR modifies our formatting of comments around the `.` in an attribute. Specifically, the goal here is to avoid _reordering_ comments, and the net effect is that we generally leave comments where-they-are when dealing with comments between around the dot (which you can also think of as comments between attributes). All comments around the dot are now treated as dangling and formatted manually, with the exception of end-of-line or parenthesized comments on the value, like those marked as trailing here, which remain trailing: ```python ( ( a # trailing end-of-line # trailing own-line ) # dangling before dot end-of-line .b # trailing end-of-line ) ``` Closes https://github.com/astral-sh/ruff/issues/6823. ## Test Plan `cargo test` Before: | project | similarity index | |--------------|------------------| | cpython | 0.76050 | | django | 0.99820 | | transformers | 0.99800 | | twine | 0.99876 | | typeshed | 0.99953 | | warehouse | 0.99615 | | zulip | 0.99729 | After: | project | similarity index | |--------------|------------------| | cpython | 0.76050 | | django | 0.99820 | | transformers | 0.99800 | | twine | 0.99876 | | typeshed | 0.99953 | | warehouse | 0.99615 | | zulip | 0.99729 |
This commit is contained in:
parent
6f23469e00
commit
474e8fbcd4
5 changed files with 216 additions and 128 deletions
|
@ -109,3 +109,19 @@ x6 = (
|
|||
# regression: https://github.com/astral-sh/ruff/issues/6181
|
||||
(#
|
||||
()).a
|
||||
|
||||
(
|
||||
(
|
||||
a # trailing end-of-line
|
||||
# trailing own-line
|
||||
) # dangling before dot end-of-line
|
||||
.b # trailing end-of-line
|
||||
)
|
||||
|
||||
(
|
||||
(
|
||||
a
|
||||
)
|
||||
# dangling before dot own-line
|
||||
.b
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue