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. #1866

Closed
adamhammes opened this issue Dec 12, 2020 · 1 comment
Closed
Labels
C: invalid code Black destroyed a valid Python file T: bug Something isn't working

Comments

@adamhammes
Copy link

adamhammes commented Dec 12, 2020

Describe the bug A clear and concise description of what the bug is.

Black won't format my file, and the error message said to report it.

To Reproduce Steps to reproduce the behavior:

  1. Take this file: Black playground link
class Orientation(enum.IntEnum):
    North = 0
    East = 1
    South = 2
    West = 3

    def as_coords(self) -> Point:
        # fmt: off
        return Point(*{
            Orientation.North: ( 0,  1),
            Orientation.East:  ( 1,  0),
            Orientation.South: ( 0, -1),
            Orientation.West:  (-1,  0),
        }[self])

    @staticmethod
    def from_char(c: str) -> 'Orientation':
        pass
  1. See error: INTERNAL ERROR: Black produced code that is not equivalent to the source.
  • Version: [e.g. master]: v20.8b1
  • Black Playground, as well as macOS Mojave w/ Python 3.8

Does this bug also happen on master? To answer this, you have two options:

Yes, playground link

Additional context Add any other context about the problem here.

Nothing to add, just wanted to say that I love this tool!

@adamhammes adamhammes added the T: bug Something isn't working label Dec 12, 2020
@ichard26
Copy link
Collaborator

Another case of #569.

I recommend you add fmt: on after the }[self]) line so you don't get bit by a pretty bad indentation bug when fmt: off applies after the end of scope.

Nothing to add, just wanted to say that I love this tool!

Thank you! Also thanks for submitting this bug report!

@ichard26 ichard26 added the C: invalid code Black destroyed a valid Python file label Dec 14, 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 T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants