-
Notifications
You must be signed in to change notification settings - Fork 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 instability: hard line break in binary expression #7605
Comments
I updated the summary with a smaller reproduction |
Thanks. |
Didn't mean to assign to myself 😂 |
I think this is caused by #6588 The binary expression can have dangling comments and it formats them manually. But it's the comprehension that attaches a dangling comment to the binary expression, which messes up the formatting logic, which it intends to handle but the binary expression formatting can't know that. The solution here is that comprehension shouldn't attach dangling comments to other nodes. |
I can fix that. |
The problematic comment placement are: ruff/crates/ruff_python_formatter/src/comments/placement.rs Lines 2124 to 2131 in 865c898
Not related to this issue but has the same underlying problem ruff/crates/ruff_python_formatter/src/comments/placement.rs Lines 2158 to 2164 in 865c898
|
Given:
We format as:
(Notice the hard line break between
+
andc # negative decimal
.)Which is then formatted as:
Sourced from #7590 (
A_1798643049678049848.py
).The text was updated successfully, but these errors were encountered: