-
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
Improve String Handling #1132
Improve String Handling #1132
Conversation
274715a
to
8592d46
Compare
This commit signifigantly dirties up the code introduced in this PR (psf#1132). I plan to clean all of this up considerably before merging with master.
c74192d
to
4d42b81
Compare
2a93aa3
to
e0eec91
Compare
@bbugyi200, sorry for the ping. I have a question if this formatting is intended or not. (black) richard-26@ubuntu-laptop:~/programming/black$ black test.py --diff --color
--- test.py 2020-07-20 00:40:48.843094 +0000
+++ test.py 2020-07-20 00:40:50.391909 +0000
@@ -10,11 +10,6 @@
-raise ValueError(
- 'Invalid input:\n'
- f' * x={x}\n'
- f' * y={y}\n'
- f' * z={z}'
-)
+raise ValueError(f"Invalid input:\n * x={x}\n * y={y}\n * z={z}") At first, I assumed this wouldn't happen because of "Manual user splits will be respected when it is possible to do so without violating the line length limit" Is this string literal merging related to "Unnecessary surrounding parens will be stripped from strings and adjacent short strings will be merged when possible"? Or is the "manual user splits" protection is only for assignments? Asking since I am a bit surprised at Black's output from this issue: #1540 Thanks! |
@ichard26 No problem. Let's look at how black handled this example before compared to how it does now: ##### INPUT
raise ValueError(
'Invalid input:\n'
f' * x={x}\n'
f' * y={y}\n'
f' * z={z}'
)
##### OLD OUTPUT
raise ValueError("Invalid input:\n" f" * x={x}\n" f" * y={y}\n" f" * z={z}")
##### NEW OUTPUT
raise ValueError(f"Invalid input:\n * x={x}\n * y={y}\n * z={z}") So the only thing that #1132 has changed about this output is that the strings are merged together. |
This pull request's main intention is to wrap long strings (as requested by #182); however, it also provides better string handling in general and, in doing so, closes the following issues:
Closes #26
Closes #182
Closes #933
Closes #1183
Closes #1243
Examples
f
prefix will be dropped when possible: