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: Black produced different code on the second pass of the formatter #2055

Closed
trygveaa opened this issue Mar 20, 2021 · 2 comments
Labels
C: unstable formatting Formatting changed on the second pass R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@trygveaa
Copy link

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Take this file: https://github.com/wee-slack/wee-slack/blob/bf9ef6f4bcd580a9b4ba858537d0a99cae7bb87e/wee_slack.py
  2. Run Black on it with these arguments: black wee_slack.py
  3. See error:
error: cannot format wee_slack.py: INTERNAL ERROR: Black produced different code on the second pass of the formatter.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /tmp/blk_wg5ef8k0.log
Oh no! 💥 💔 💥
1 file failed to reformat.

blk_wg5ef8k0.log

Expected behavior A clear and concise description of what you expected to happen.

Black should format the file.

Environment (please complete the following information):

  • Version: 20.8b1 and master
  • OS and Python version: Linux/Python 3.9.2

Does this bug also happen on master? To answer this, you have two options:

Yes

@trygveaa trygveaa added the T: bug Something isn't working label Mar 20, 2021
@trygveaa
Copy link
Author

If I run black --fast, it does manage to reformat. If I then touch the file (otherwise black won't do anything the second time) and run black again (with or without --fast), I get this diff:

diff --git a/wee_slack.py b/wee_slack.py
index d0290ae..c9d0c60 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3279,10 +3279,14 @@ class SlackMessage(object):
         if self.message_json.get("mrkdwn", True):
             text = render_formatting(text)
 
-        if self.message_json.get("subtype") in (
-            "channel_join",
-            "group_join",
-        ) and self.message_json.get("inviter"):
+        if (
+            self.message_json.get("subtype")
+            in (
+                "channel_join",
+                "group_join",
+            )
+            and self.message_json.get("inviter")
+        ):
             inviter_id = self.message_json.get("inviter")
             text += " by invitation from <@{}>".format(inviter_id)
 

If I run black subsequent times after that, it doesn't change anything more.

@ichard26 ichard26 added the C: unstable formatting Formatting changed on the second pass label Mar 24, 2021
@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Apr 25, 2021
@ichard26
Copy link
Collaborator

Hello!

All reproduction cases in this issue format without error on master. The fixing commit was 8672af3 from PR GH-2126. I'll be marking this issue as a duplicate of GH-1629 since that's what GH-2126 aimed to fix and it's highly likely this issue falls under GH-1629.

Since we use the issue tracker as a reflection of what's on master, I'll be closing this issue. If you have any issues, especially with the new (but stable) output, please open a new issue. Oh and the fix should be available in a published release soon, see GH-2125 for more info.

Thank you for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: unstable formatting Formatting changed on the second pass 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