-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Formatter: Unstable call arguments comment formatting #6818
Comments
@MichaReiser - Want me to look at this, or are you taking as part of #6817? |
I'm not solving it. I used a different test case to work around the issue. |
I'm thinking that I'll just make that a leading comment on |
Prettier makes it a leading comment of what comes after Playground. You have to be careful with comment ordering if you make it a leading comment of |
I need to understand why we break the latter but not the former: aaa = (
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
# awkward comment
()
.bbbbbbbbbbbbbbbb
)
aaa = (
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
()
# awkward comment
.bbbbbbbbbbbbbbbb
) |
Attribute formatting has special handling for leading comments of the next attribute ruff/crates/ruff_python_formatter/src/expression/expr_attribute.rs Lines 113 to 117 in 0cea497
|
## Summary We now format comments between a function and its arguments as dangling. Like with other strange placements, I've biased towards preserving the existing formatting, rather than attempting to reorder the comments. Closes #6818. ## 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 |
I created this example to test some edge cases with #6817. That PR is handling the edge case correctly but I can't add the test case because the call expression formatting with the following comment itself is unstable
Playground
The text was updated successfully, but these errors were encountered: