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 using #fmt: off #1805

Closed
williamjamir opened this issue Nov 4, 2020 · 1 comment
Closed

Internal Error when using #fmt: off #1805

williamjamir opened this issue Nov 4, 2020 · 1 comment
Labels
C: invalid code Black destroyed a valid Python file R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@williamjamir
Copy link

williamjamir commented Nov 4, 2020

Black v20.8b1

Playground link

Options

--line-length=88
--safe

Input

def testA():
    # fmt: off
    assert 1 == 1
    # ftm: on


def testB():
    ...

Output

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_br_2qz1n.log

--- src
+++ dst
@@ -32,46 +32,46 @@
               ops=
                 Eq(
                 )  # /Eq
             )  # /Compare
         )  # /Assert
+        FunctionDef(
+          args=
+            arguments(
+              args=
+              defaults=
+              kw_defaults=
+              kwarg=
+                None,  # NoneType
+              kwonlyargs=
+              posonlyargs=
+              vararg=
+                None,  # NoneType
+            )  # /arguments
+          body=
+            Expr(
+              value=
+                Constant(
+                  kind=
+                    None,  # NoneType
+                  value=
+                    Ellipsis,  # ellipsis
+                )  # /Constant
+            )  # /Expr
+          decorator_list=
+          name=
+            'testB',  # str
+          returns=
+            None,  # NoneType
+          type_comment=
+            None,  # NoneType
+        )  # /FunctionDef
       decorator_list=
       name=
         'testA',  # str
       returns=
         None,  # NoneType
       type_comment=
         None,  # NoneType
     )  # /FunctionDef
-    FunctionDef(
-      args=
-        arguments(
-          args=
-          defaults=
-          kw_defaults=
-          kwarg=
-            None,  # NoneType
-          kwonlyargs=
-          posonlyargs=
-          vararg=
-            None,  # NoneType
-        )  # /arguments
-      body=
-        Expr(
-          value=
-            Constant(
-              kind=
-                None,  # NoneType
-              value=
-                Ellipsis,  # ellipsis
-            )  # /Constant
-        )  # /Expr
-      decorator_list=
-      name=
-        'testB',  # str
-      returns=
-        None,  # NoneType
-      type_comment=
-        None,  # NoneType
-    )  # /FunctionDef
   type_ignores=
 )  # /Module

Observation

If I remove either # fmt or testB than everything works fine.

@williamjamir williamjamir changed the title Internal Error Internal Error when using #fmt: off Nov 4, 2020
@ichard26 ichard26 added T: bug Something isn't working R: duplicate This issue or pull request already exists C: invalid code Black destroyed a valid Python file labels Nov 4, 2020
@ichard26
Copy link
Collaborator

ichard26 commented Nov 4, 2020

Hey thanks for reporting but I'm closing this issue as it is a duplicate of #569.

@ichard26 ichard26 closed this as completed Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: invalid code Black destroyed a valid Python file 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