Skip to content
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 throws an error when formatting string #1607

Closed
dkuku opened this issue Aug 17, 2020 · 6 comments
Closed

black throws an error when formatting string #1607

dkuku opened this issue Aug 17, 2020 · 6 comments
Labels
T: bug Something isn't working

Comments

@dkuku
Copy link

dkuku commented Aug 17, 2020

Describe the bug A clear and concise description of what the bug is.
black throws an error on my comment -
To Reproduce Steps to reproduce the behavior:

class CITNowEvent(Resource):
    def post(self):
        """
        "event": "EVENTVIDEOPAGESERVED",  
        "server": "https://video.citnow.com",  
        "lid": "idev",  
        "lid_type": "service",  
        "dealername": "iDevices Test Site - DEALERSHIP NAME",  
        "dealerpostcode": "RG412PQ",  
        "timestamp": 1454508578 
        possible fields - the ones that we are interested
        _____________________________________
        | request | int    | Request | ID   |
        | video   | object | Video   | data |
        | vhc     | object | VHC     | data |
        """

thats the diff I get:

--- src
+++ dst
@@ -994,11 +994,11 @@
           body=
             Expr(
               value=
                 Constant(
                   value=
-                    '\n "event": "EVENTVIDEOPAGESERVED",  \n "server": "https://video.citnow.com",  \n "lid": "idev",  \n "lid_type": "service",  \n "dealername": "iDevices Test Site - DEALERSHIP NAME",  \n "dealerpostcode": "RG412PQ",  \n "timestamp": 1454508578 \n possible fields - the ones that we are interested\n _____________________________________\n | request | int    | Request | ID   |\n | video   | object | Video   | data |\n | vhc     | object | VHC     | data |\n ',  # str
+                    '\n "event": "EVENTVIDEOPAGESERVED",\n "server": "https://video.citnow.com",\n "lid": "idev",\n "lid_type": "service",\n "dealername": "iDevices Test Site - DEALERSHIP NAME",\n "dealerpostcode": "RG412PQ",\n "timestamp": 1454508578\n possible fields - the ones that we are interested\n _____________________________________\n | request | int    | Request | ID   |\n | video   | object | Video   | data |\n | vhc     | object | VHC     | data |\n ',  # str
                 )  # /Constant
             )  # /Expr
             Return(
               value=
                 Call(

After I remove it I can fromat the file, also it should not remove whitespaces from this string

@dkuku dkuku added the T: bug Something isn't working label Aug 17, 2020
@dkuku dkuku changed the title black throws an error when formatting my comment black throws an error when formatting string Aug 17, 2020
@hugovk
Copy link
Contributor

hugovk commented Aug 17, 2020

What error is being thrown?

Testing, Black 19.10b makes no changes:

$ black --version
black, version 19.10b0
$ black 1607.py --check
All done! ✨ 🍰 ✨
1 file left unchanged.

And latest master runs without errors, but removes the spaces at the end of docstring lines:

$ black --version
black, version 19.10b1.dev141+g820f387
$ black 1607.py
reformatted 1607.py
All done! ✨ 🍰 ✨
1 file reformatted.

image

Do you mean it shouldn't remove the spaces at the end of docstrings?

@dkuku
Copy link
Author

dkuku commented Aug 17, 2020

I removed the whitespaces and it works ok but its enough to have one space at the end and it fails
I run it inside vim - the diff I pasted before, thats the error:
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_if5qr5x9.log

@dkuku
Copy link
Author

dkuku commented Aug 17, 2020

  ~/.config/nvim/.direnv/python-3.8.2/bin/black resources/citnow.py 
error: cannot format resources/citnow.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_h6yjjoey.log
Oh no! 💥 💔 💥
1 file failed to reformat.

 ~/.config/nvim/.direnv/python-3.8.2/bin/black --version
black, version 19.10b1.dev90+g2432309

@hugovk
Copy link
Contributor

hugovk commented Aug 17, 2020

I have version 19.10b1.dev141+g820f387; that devX indicates something like master is now 51 commits ahead of you.

Please could you update your Black version to the newest master and retest?

@dkuku
Copy link
Author

dkuku commented Aug 17, 2020

it works ok when I did pip -U black
false alarm

@JelleZijlstra
Copy link
Collaborator

This probably got fixed by #1593.

@dkuku pip install -U black would actually have downgraded black for you, since apparently you were previously on an unreleased commit, and the pip command would instead install the latest release (19.10b1). This bug was introduced and then fixed since that release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants