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 code that is not equivalent to the source. #2944

Closed
jonasrauber opened this issue Mar 21, 2022 · 3 comments
Closed
Labels
C: invalid code Black destroyed a valid Python file F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. F: fmtoff fmt: off implementation T: bug Something isn't working

Comments

@jonasrauber
Copy link

To Reproduce

file.py

with foo:
    # yapf: disable
    bar
baz

Run it with these arguments:

black file.py -t py39

The resulting error is:

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

  • Black's version: 22.1.0
@jonasrauber jonasrauber added the T: bug Something isn't working label Mar 21, 2022
@felix-hilden
Copy link
Collaborator

felix-hilden commented Mar 21, 2022

Reproduced on the playground. Having anything before the comment doesn't produce the error. Thanks for submitting!

@felix-hilden felix-hilden added C: invalid code Black destroyed a valid Python file F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. labels Mar 21, 2022
@jonasrauber
Copy link
Author

Here is one more that contains yapf: disable and yapf: enable (that's closer to the original code):

with foo:
    # yapf: disable
    with bar:
        # yapf: enable
        baz
pass

@JelleZijlstra JelleZijlstra added the F: fmtoff fmt: off implementation label Mar 21, 2022
@JelleZijlstra
Copy link
Collaborator

I believe we treat # yapf: disable the same as # fmt: off, so this is essentially the same as #569.

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 F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. F: fmtoff fmt: off implementation T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants