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 #950

Closed
jaimemarijke opened this issue Jul 29, 2019 · 2 comments
Closed
Labels
C: invalid code Black destroyed a valid Python file T: bug Something isn't working

Comments

@jaimemarijke
Copy link

jaimemarijke commented Jul 29, 2019

Howdy! Sorry you're having trouble. To expedite your experience,
provide some basics for me:

Operating system: Mac OS 10.14
Python version: 3.6.5
Black version: 19.3b0
Does also happen on master:

To answer the last question, you have two options:

  1. Use the online formatter at https://black.now.sh/?version=master, which will use the latest master branch.
  2. Or run black on your machine:
    • create a new virtualenv (make sure it's the same Python version);
    • clone this repository;
    • run pip install -e .;
    • make sure it's sane by running python setup.py test; and
    • run black like you did last time.

Just dropping by here because it told me to: "error: cannot format /Users/jaime/osmo/cosmobot-deep-learning/cosmobot_deep_learning/preprocess_image_test.py: INTERNAL ERROR: Black produced code that is not equivalent to the source. Please report a bug on https://github.com/ambv/black/issues. This diff might be helpful: /var/folders/5g/6ydq2ctj7px9fkq309znm_fr0000gn/T/blk_d_si_ol7.log"

blk_d_si_ol7.log

I don't actually care about the issue so if this info isn't helpful please feel free to close.

@jaimemarijke
Copy link
Author

Actually, a seemingly related piece of information. My code looked something like this:

class TestMyFunctionA:
    # fmt: off
    @pytest.mark.parametrize(
        "some_parameter_a, some_parameter_b",
        [
            (
                "1",
                "2",
            ),
           (
                "3",
                "4",
            ),
        ],
    )
    # fmt: on
    def test_my_function(self, some_parameter_a, some_parameter_b):
        <some tests>
        ...

class TestMyFunctionB:
    def test_my_func(self):
        <some tests>

This caused black to break. When I moved the location of the # fmt: off block as below, without changing anything else, black stopped breaking.

class TestMyFunctionA:
    # fmt: off
    @pytest.mark.parametrize(
        "some_parameter_a, some_parameter_b",
        [
            # fmt: off
            (
                "1",
                "2",
            ),
           (
                "3",
                "4",
            ),
            # fmt: on
        ],
    )
    def test_my_func(self, some_parameter_a, some_parameter_b):
        <some tests>
        ...

class TestMyFunctionB:
    def test_my_func(self):
        <some tests>
        ...

@zsol zsol added T: bug Something isn't working C: invalid code Black destroyed a valid Python file labels Jul 30, 2019
@zsol
Copy link
Collaborator

zsol commented Jul 30, 2019

Thanks for reporting! Looks like this is a duplicate of #560

@zsol zsol closed this as completed Jul 30, 2019
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