-
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 reformats docstrings #1779
Comments
A few relevant comments in a closed issue about docstrings
|
I am having a similar issue. When I am using the Click package for CLI, and employ the use of "\b" and "\f" for controlled formatting per https://click.palletsprojects.com/en/8.0.x/documentation/#preventing-rewrapping, then black reformats this docstring and mangles the CLI help-text. |
@jeremyschulman could you report an issue for that? I'd be open to specifically preserving |
@JelleZijlstra What is the problem with having an option to prevent formatting of docstrings completely? |
We prefer to minimize options that affect formatting. It's also a better user experience for Click users if Black doesn't mangle their docstring in the first place than if they have to hunt for an option. |
Oh I totally agree - it's better for _everyone_ not to mangle their
docstrings in the first place. 🙄
…On Sat, 23 Oct 2021, 01:10 Jelle Zijlstra, ***@***.***> wrote:
We prefer to minimize options that affect formatting. It's also a better
user experience for Click users if Black doesn't mangle their docstring in
the first place than if they have to hunt for an option.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1779 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVG3A7NMTFRPLTV4HQ3FPTTUIH4PVANCNFSM4S3OTEPA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
@JelleZijlstra - I have created issue #2565 per your request. Thank you for supporting black. I love it! |
Black broke the RST in some of our docstrings.
There are other constructs that need to be indented correctly as well. |
@mixmastamyk could you be more specific? It seems to work fine on the playground. |
Probably an old version:
Nope, upgraded and this does the same:
If perhaps you are not familiar with RST, the indent on the second line is required to be indented to signify a preformated section. As RST is used heavily in Python projects I'm surprised this is the case. Maybe I've done something wrong. 🤔 |
Oh, this is likely just a special case of the first line being involved. We leave it in but standardise the indentation in the general body, so the "block" is dedented. Is your style accepted by Sphinx? |
No, RST treats the dedented text as regular body text. But, I think I know what you are saying now. Another line in there would fix it. |
I guess this is tolerable, but think I'd prefer not having to outsmart the formatter. |
I tested it: Sphinx does not accept your format. It warns about "literal block expected; none found" and outputs ordinary text. So are you using some other tool? |
Black is what broke the .rst formatting. I wish it didn't do this, and didn't ask for it. But, seems easy to work around. |
I meant that the unedited example you described was not accepted by Sphinx, producing the error I provided. I did not format with black before building. |
Describe the bug
Black unexpectedly changes the indentation of docstrings.
To Reproduce Steps to reproduce the behavior:
Run Black on it with no arguments.
The file now looks like this:
Expected behavior
The file should not change.
Environment (please complete the following information):
black, version 20.8b1
Does this bug also happen on master?
Yes: https://black.now.sh/?version=master&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AERAI9dAD2IimZxl1N_WlbvK5V_r8p8R-QE02W0lfkJhkx4HULNTeXtLhBSpJmQpwGtlUvdJejSQJkMO6dLzygF-JFcvh-GgHC_wXD7PkS9n_u3ZNIEjx21NLS3PZDa8hVIXSPbpnHxFjE9s9CpuDGtiWTGVnMmoNBDg1cWmglrQAzN90l7lG5DkXLLpb9UER5YwF4AAADqLgMjoNolCwABqwGSAgAAAeEjmbHEZ_sCAAAAAARZWg==
Additional context
I understand that Black is opinionated and is trying to enforce PEP 257 verbatim, but there should at least be a switch to disable docstring formatting.
The text was updated successfully, but these errors were encountered: