-
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: deviation from Black when line splitting subscript assignment #9781
Comments
Black used to use the style ruff currently uses, but was changed late 2022. This was the issue: psf/black#1498 |
Thanks for reporting this issue. Is it possible that you use/used black 24? Or what black version are you using? |
That is correct.
|
I can confirm this change was introduced in Black 24.1: https://github.com/psf/black/blob/main/CHANGES.md#2410
Setting the format.preview setting to true changes this behaviour to match Black. |
So, Black 24.1 moved a lot of preview style rules into it's stable style (psf/black#4042). We've implemented the same in our own preview style formatting which can be enabled through If you run the mentioned code snippet under the preview style then you'd get the same output: ruff format --preview --diff --- /Users/dhruv/playground/ruff/formatter/isolated.py
+++ /Users/dhruv/playground/ruff/formatter/isolated.py
@@ -1 +1,3 @@
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa["bbbbbbbbbbbbbbbbbbbb"] = "ccccccccccc"
+aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa["bbbbbbbbbbbbbbbbbbbb"] = (
+ "ccccccccccc"
+) You can track the progress of the pull request which will promote the same preview style rules into stable style for Ruff here: #9639 I hope this helps :) |
It sure does. Thank you for your help. I'll close this issue, since I believe it does not provide any extra value at this point. |
Ruff splits lines differently when the line length exceeds the configured line length, and the line contains assignment using subscript notation. For instance, when assigning to a dict.
I had a look at the known deviations, and at other open issues, but could not find this deviation.
Input:
Black output:
Ruff (
ruff format --isolated file.py
) output:Ruff version:
The text was updated successfully, but these errors were encountered: