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

Comments removed in pyi files #1239

Closed
juliatuttle opened this issue Jan 20, 2020 · 3 comments · Fixed by #3745
Closed

Comments removed in pyi files #1239

juliatuttle opened this issue Jan 20, 2020 · 3 comments · Fixed by #3745
Labels
C: crash Black is crashing F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: bug Something isn't working

Comments

@juliatuttle
Copy link

Hi! I accidentally ran black on my entire venv in a project, and one of the files it spat out "INTERNAL ERROR: Black produced code that is not equivalent to the source." on was typeshed/stdlib/3/configparser.pyi. I'm not sure what version of typeshed that is, but the issue doesn't repro with the current version on GitHub.

Regardless, here's the diff:

--- src
+++ dst
@@ -5135,8 +5135,6 @@
   type_ignores=
     TypeIgnore(
     )  # /TypeIgnore
     TypeIgnore(
     )  # /TypeIgnore
-    TypeIgnore(
-    )  # /TypeIgnore
 )  # /Module
@JelleZijlstra
Copy link
Collaborator

Would you mind sending the version of the file that you were running Black on? Even better would be if you could minimize it to just the part of the file that the bug is triggered on :)

@juliatuttle
Copy link
Author

Okay, I seem to have an absurdly tiny repro case:

(venv) julia@causeway:/tmp$ cat bad.pyi 
def f():  # type: ignore
    ...
(venv) julia@causeway:/tmp$ black bad.pyi 
error: cannot format bad.pyi: 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_gl3r8wl1.log
Oh no! 💥 💔 💥
1 file failed to reformat.
(venv) julia@causeway:/tmp$ cat /tmp/blk_gl3r8wl1.log
--- src
+++ dst
@@ -25,8 +25,6 @@
         None,  # NoneType
       type_comment=
         None,  # NoneType
     )  # /FunctionDef
   type_ignores=
-    TypeIgnore(
-    )  # /TypeIgnore
 )  # /Module
(venv) julia@causeway:/tmp$ cat good.pyi 
def f():
    ...
(venv) julia@causeway:/tmp$ black good.pyi 
reformatted good.pyi
All done! ✨ 🍰 ✨
1 file reformatted.

@JelleZijlstra JelleZijlstra changed the title Code not equivalent to source: typeshed/stdlib/3/configparser.pyi Comments removed in pyi files May 29, 2021
@JelleZijlstra JelleZijlstra added F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: bug Something isn't working labels May 30, 2021
@JelleZijlstra JelleZijlstra added the C: crash Black is crashing label Apr 29, 2023
@JelleZijlstra
Copy link
Collaborator

Still reproduces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: crash Black is crashing F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants