-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
formatter deviation: line break not occurring on assignments where LHS goes over line-length #11820
Comments
I think this is related to #8940 |
Yes, I can confirm that #8940 would fix the deviation. The problem is, that the PR has a few regressions around call expression formatting, which is why the PR was abandoned. So fixing this requires some more work and is also something that I don't think we can fix outside of a new formatter style guide as it would change how already formatted code gets formatted. But we should have a second look at this when we work on the next formatter style guide to see if we can match Black more closely. The main issue here is that Ruff doesn't parenthesize the expression if the |
deviations from black: * astral-sh/ruff#11820
deviations from black: * astral-sh/ruff#11820
deviations from black: * https://docs.astral.sh/ruff/formatter/black/#call-chain-calls-break-differently-in-some-cases * https://docs.astral.sh/ruff/formatter/black/#own-line-comments-on-expressions-dont-cause-the-expression-to-expand * https://docs.astral.sh/ruff/formatter/black/#trailing-commas-are-inserted-when-expanding-a-function-definition-with-a-single-argument * astral-sh/ruff#11820 * astral-sh/ruff#14143 * astral-sh/ruff#8598
deviations from black: * astral-sh/ruff#11820
I'm seeing a case where black is expanding an assignment but ruff is not - even re-writing the black formatted result.
To keep it concise, this example uses an ultra-short line-length of 14:
Input
Black:
Ruff:
This seems to occur only when the name of the variable assigned to, is longer than line-length (so expanding the line won't bring it within the allowed length).
I can't find this in the documented deviations or other issues at present, and this doesn't seem to be a duplicate of another issue.
The text was updated successfully, but these errors were encountered: