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

hug_parens_with_braces_and_square_brackets: "Black produced code that is not equivalent to the source" error in preview mode on function call with two type:ignore comments #4036

Open
DetachHead opened this issue Nov 9, 2023 · 2 comments · May be fixed by #4037
Labels
C: crash Black is crashing C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. T: bug Something isn't working

Comments

@DetachHead
Copy link

foo(  # type:ignore
    [  # type:ignore
        a
    ]
)
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_qaa1dff6.log

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

playground

@DetachHead DetachHead added the T: bug Something isn't working label Nov 9, 2023
@DetachHead DetachHead changed the title "Black produced code that is not equivalent to the source" error in preview mode on function call with two type:ignore "Black produced code that is not equivalent to the source" error in preview mode on function call with two type:ignore comments Nov 9, 2023
@JelleZijlstra JelleZijlstra added C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. C: crash Black is crashing labels Nov 9, 2023
@JelleZijlstra
Copy link
Collaborator

Thanks! cc @henriholopainen for the single-argument call hugging change.

@JelleZijlstra JelleZijlstra changed the title "Black produced code that is not equivalent to the source" error in preview mode on function call with two type:ignore comments hug_parens_with_braces_and_square_brackets: "Black produced code that is not equivalent to the source" error in preview mode on function call with two type:ignore comments Jan 30, 2024
JelleZijlstra added a commit to JelleZijlstra/black that referenced this issue Jan 31, 2024
Primarily because of psf#4036 (a crash) but also because of the feedback
in psf#4098 and psf#4099.
JelleZijlstra added a commit that referenced this issue Feb 2, 2024
…le (#4198)

Primarily because of #4036 (a crash) but also because of the feedback
in #4098 and #4099.
@bukzor
Copy link

bukzor commented May 23, 2024

The example above currently does not crash:

$ black --version
black, 24.4.2 (compiled: yes)
Python (CPython) 3.12.3

$ cat example.py
foo(  # type:ignore
    [  # type:ignore
        a
    ]
)

$ black --enable-unstable-feature=hug_parens_with_braces_and_square_brackets  example.py
All done! ✨ 🍰 ✨
1 file left unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: crash Black is crashing C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. T: bug Something isn't working
Projects
None yet
3 participants