-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Trailing whitespace not preserved in docstring #1462
Comments
#1417 fixed a very similar crash, are you sure you are running on current master? |
Pretty sure. Just reconfirmed again on the new HEAD of master. $ cat -E demo.py
def func():$
"""$
Line with trailing whitespace $
$
Another line with trailing whitespace $
$
Done.$
"""$
pass$
$ python -c "import black; print(black.__version__)"
19.10b1.dev1+g3461338
$ git log -n 1 HEAD
commit 34613383abad9afa5cc1b3945e50bbfca13d036e (HEAD -> master, upstream/master, upstream/HEAD)
Author: Richard Si <63936253+ichard26@users.noreply.github.com>
Date: Tue May 26 22:42:07 2020 -0400
Make 'python -m black' work (#1460)
$ python -m black demo.py
error: cannot format demo.py: INTERNAL ERROR: Black produced code that is not equivalent to the source. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /tmp/blk_c_1s9bnx.log
Oh no! 💥 💔 💥
1 file failed to reformat.
$ cat /tmp/blk_c_1s9bnx.log
--- src
+++ dst
@@ -16,11 +16,11 @@
body=
Expr(
value=
Constant(
value=
- 'Line with trailing whitespace \n\n Another line with trailing whitespace \n\n Done.', # str
+ 'Line with trailing whitespace\n\n Another line with trailing whitespace\n\n Done.', # str
) # /Constant
) # /Expr
Pass(
) # /Pass
decorator_list= |
This is a regression from |
You did not say this happens on 19.10b0 in issue description 🤔 |
Actually, this does not seem to be happening on 19.10b0. My apologies! |
This also doesn't happen on (black-rHKUX7ap) R:\Programming\black>black temp.py --diff --color
--- temp.py 2020-08-30 16:41:16.245384 +0000
+++ temp.py 2020-08-30 16:41:33.472229 +0000
@@ -1,9 +1,9 @@
def func():
"""
- Line with trailing whitespace
+ Line with trailing whitespace
- Another line with trailing whitespace
+ Another line with trailing whitespace
Done.
"""
pass
would reformat temp.py
All done! ✨ 🍰 ✨
1 file would be reformatted. Environment:
|
Describe the bug Trailing whitespace in docstrings is not preserved.
To Reproduce Steps to reproduce the behavior:
Expected behavior Trailing whitespace should be preserved or black should not complain.
Environment (please complete the following information):
Does this bug also happen on master?
It does happen on master. However, it does not happen at https://black.now.sh/?version=master. I'm not sure if that editor might be deleting the trailing whitespace?
The text was updated successfully, but these errors were encountered: