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 multiple fmt: skip #3608

Open
BenjaminBossan opened this issue Mar 16, 2023 · 1 comment · May be fixed by #3978
Open

INTERNAL ERROR when using multiple fmt: skip #3608

BenjaminBossan opened this issue Mar 16, 2023 · 1 comment · May be fixed by #3978
Labels
F: fmtskip fmt: skip implementation T: bug Something isn't working

Comments

@BenjaminBossan
Copy link

Describe the bug

Using multiple # fmt: skip in the same expression causes an INTERNAL ERROR.

To Reproduce

The first example (a) works but all others fail:

a = (
    "this should "  # fmt: skip
    "be fine"
)

b = (
    "this is "  # fmt: skip
    "not working"  # fmt: skip
)

c = (
    "and neither "  # fmt: skip
    "is this "  # fmt: skip
    "working"
)

d = (
    "nor "
    "is this "  # fmt: skip
    "working"  # fmt: skip
)

e = (
    "and this "  # fmt: skip
    "is definitely "
    "not working"  # fmt: skip
)

The resulting error is:

INTERNAL ERROR: Black produced code that is not equivalent to the source

Log:

--- src
+++ dst
@@ -33,11 +33,11 @@
       value=
         Constant(
           kind=
             None,  # NoneType
           value=
-            'this is not working',  # str
+            'this is',  # str
         )  # /Constant
     )  # /Assign
     Assign(
       targets=
         Name(
@@ -52,11 +52,11 @@
       value=
         Constant(
           kind=
             None,  # NoneType
           value=
-            'and neither is this working',  # str
+            'and neither working',  # str
         )  # /Constant
     )  # /Assign
     Assign(
       targets=
         Name(
@@ -71,11 +71,11 @@
       value=
         Constant(
           kind=
             None,  # NoneType
           value=
-            'nor is this working',  # str
+            'nor is this',  # str
         )  # /Constant
     )  # /Assign
     Assign(
       targets=
         Name(
@@ -90,10 +90,10 @@
       value=
         Constant(
           kind=
             None,  # NoneType
           value=
-            'and this is definitely not working',  # str
+            'and this not working',  # str
         )  # /Constant
     )  # /Assign
   type_ignores=
 )  # /Module
\ No newline at end of file

Expected behavior

The lines should be left untouched.

Environment

  • black, 22.12.0 (compiled: yes)
  • Python (CPython) 3.10.9
  • Ubuntu 22.04

Can also be reproduced on https://black.vercel.app.

Additional context

Maybe I'm using fmt: skip incorrectly, but documentation on it is very sparse.

@BenjaminBossan BenjaminBossan added the T: bug Something isn't working label Mar 16, 2023
@JelleZijlstra JelleZijlstra added the F: fmtskip fmt: skip implementation label Mar 16, 2023
@max-wittig
Copy link

max-wittig commented Apr 12, 2024

Maybe I got the same here:

error: cannot format serializers.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/lg/s80890fd1ts6s1w69c8lg03m0000gn/T/blk_v5h775n6.log

--- src
+++ dst
@@ -1593,8 +1593,6 @@
     type_ignores=
     TypeIgnore(
     )  # /TypeIgnore
     TypeIgnore(
     )  # /TypeIgnore
-    TypeIgnore(
-    )  # /TypeIgnore
 )  # /Module
\ No newline at end of file

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

Successfully merging a pull request may close this issue.

3 participants