-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Black fail to format long strings and comments #1331
Comments
@neoglez Black currently doesn't wrap long string literals or merge string literals that happen to be on the same line. There is an open issue regarding this: #182. I would also have to guess Black doesn't wrap long comments for the same reason for strings. It would require modifying the AST which isn't 100% safe and has a bunch of edge cases to be dealt with. Although it should be mentioned that there is a pull request for better string handling, it is #1132. Except, it is a very large PR and probably will take a lot of time to become merged. Just a 'in case you didn't know' since your issue appears to be a bug report IMO. |
#1132 has been merged but apparently black still doesn't wrap long lines, even if they contain spaces. I even tried with the very same example given in #1132's description and it doesn't work:
|
@ichard26 thanks for the pointer! |
@ichard26 Why isn't |
It's experimental! We plan to turn it on by default in the future. |
git has loads of experimental features, they are still mentioned in the cli docs. How else are people supposed to try them so you can receive more testing + feedback :) |
With the latest version of black (22.1) this is now enabled by using the |
Hi there, i'm still unable to format long comments with the version info- black, 22.3.0 (compiled: yes) Test file: def boom() -> None:
"""There’s an increasing regulatory and consumer pressure on companies to do a better job protecting sensitive customer data. Yet, despite this pressure, data breaches and compliance issues continue to plague the tech industry."""
# There’s an increasing regulatory and consumer pressure on companies to do a better job protecting sensitive customer data. Yet, despite this pressure, data breaches and compliance issues continue to plague the tech industry
pass Command output: root@ca9009d07c58:/opt/# black -v --line-length 80 --preview test_line.py
Identified `/opt/` as project root containing a .git directory.
Sources to be formatted: "test_line.py"
Using configuration from project root.
test_line.py wasn't modified on disk since last run.
All done! ✨ 🍰 ✨
1 file left unchanged. Am I missing something? My understanding is that the functionality is protected behind |
The |
JFYI, the issue is still in-place for me:
does not split long string fields. my versions are: |
Do you plan to strip comment line also ? Flake is raising error, Black doesn't allow us to solve them. |
From Version 24.1.0,
|
Black 9ed254
Playground link
Options
--line-length=88
Input
Output
Expected
Output
The text was updated successfully, but these errors were encountered: