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

INTERNAL ERROR when formatting docstrings containing literal tab characters #1638

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

Comments

@amyreese
Copy link
Contributor

To Reproduce

black-repro-tabs.py:

class C:
    """
    Words	With	Tabs
    """
    pass
(venv38) jreese@garbodor ~/scratch » black --diff --safe black-repro-tabs.py
error: cannot format black-repro-tabs.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: /var/folders/_b/6gpzshq548d4d_4bk1m5sq280000gn/T/blk_epxedyba.log
Oh no! 💥 💔 💥
1 file would fail to reformat.
(venv38) jreese@garbodor ~/scratch ‹123› » cat /var/folders/_b/6gpzshq548d4d_4bk1m5sq280000gn/T/blk_epxedyba.log
--- src
+++ dst
@@ -5,11 +5,11 @@
       body=
         Expr(
           value=
             Constant(
               value=
-                'Words\tWith\tTabs',  # str
+                'Words       With    Tabs',  # str
             )  # /Constant
         )  # /Expr
         Pass(
         )  # /Pass
       decorator_list=

Expected behavior

Should be formatted using consistent tab characters (or replaced with spaces? 🤷) on both passes.

Environment (please complete the following information):

  • Version: 20.8b1
  • OS and Python version: Python 3.8.5 on Linux and

Does this bug also happen on master?**

Yes.

Additional context

@thatch says git bisect points to a4c11a7 where docstring formatting was introduced.

@amyreese amyreese added the T: bug Something isn't working label Aug 27, 2020
@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Aug 27, 2020
@ichard26
Copy link
Collaborator

Hello @jreese, this is a duplicate of #1601. Thanks for filing, perhaps +1 the original issue?

@peterjc
Copy link

peterjc commented Aug 27, 2020

Duplicate with black 20.8b1 (wasn't immediately obvious to me it was failing within docstrings):

biopython/biopython#3236

This seems different to #1601 which was reported on 19.10b0 and from the discussion was specific to tabs at the end of a line.

@ichard26
Copy link
Collaborator

ichard26 commented Aug 27, 2020

This seems different to #1601 which was reported on 19.10b0 and from the discussion was specific to tabs at the end of a line.

I view that issue as for all "Black produced code that is not equivalent to the source" errors due to tabs in docstrings being replaced since the responsible commit (a4c11a7) and possible fix for all these cases is the same. Also the original bug with tabs at the end still exists as of version 20.08b1.

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

3 participants