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 removes tabs from within docstrings and thus not equivalent to the source #1651

Closed
d0ugal opened this issue Aug 28, 2020 · 2 comments
Closed
Labels
R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@d0ugal
Copy link

d0ugal commented Aug 28, 2020

Describe the bug

I got this error when formatting MAAS code.

error: cannot format src/provisioningserver/drivers/pod/virsh.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__oj12ra3.log
Oh no! 💥 💔 💥
1 file failed to reformat.

The diff contains...

--- src
+++ dst
@@ -17834,11 +17834,11 @@
           body=
             Expr(
               value=
                 Constant(
                   value=
-                    'Calculate a block name based on the `idx`.\n\nDrive#  Name\n0\t    vda\n25\t    vdz\n26\t    vdaa\n27\t    vdab\n51\t    vdaz\n52\t    vdba\n53\t    vdbb\n701\t    vdzz\n702\t    vdaaa\n703\t    vdaab\n18277   vdzzz',  # str
+                    'Calculate a block name based on the `idx`.\n\nDrive#  Name\n0           vda\n25          vdz\n26          vdaa\n27          vdab\n51          vdaz\n52          vdba\n53          vdbb\n701         vdzz\n702         vdaaa\n703         vdaab\n18277   vdzzz',  # str
                 )  # /Constant
             )  # /Expr
             Assign(
               targets=
                 Name(

To Reproduce Steps to reproduce the behavior:

  1. Take this file https://github.com/maas/maas/blob/6620973/src/provisioningserver/drivers/pod/virsh.py
    1.1. wget https://raw.githubusercontent.com/maas/maas/6620973567f4081a4c5ada8ea2720dc079c0f23d/src/provisioningserver/drivers/pod/virsh.py
  2. Run Black on it with just the filename
    2.1 black virsh.py
  3. See error above

Expected behavior

It looks like black is changing tabs within the docstring, I wouldn't expect this to happen.

Environment (please complete the following information):

  • Version: 20.8.b1 (and tested on master which was 2b75f88 at the time)
  • OS and Python version: Ubuntu and Python 3.8.4 (and also tested 3.8.2 on another ubuntu box)

Does this bug also happen on master?

Yes, confirmed with pip install git+https://github.com/psf/black in a virtualenv

@d0ugal d0ugal added the T: bug Something isn't working label Aug 28, 2020
@d0ugal d0ugal changed the title Black removes tabs from within docstrings and thus not equivilent to the source Black removes tabs from within docstrings and thus not equivalent to the source Aug 28, 2020
@d0ugal
Copy link
Author

d0ugal commented Aug 28, 2020

@sparkiegeek pointed out to me that this might be a dupe of #1601

@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Aug 28, 2020
@ichard26
Copy link
Collaborator

@d0ugal yeah this is a duplicate of #1601. Thank you for the bug report, perhaps +1 the original issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R: duplicate This issue or pull request already exists T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants