-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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. #1616
Comments
Thanks for the report! Since this is fixed on master and we're planning to have a new release soon, I'm not sure there's anything else for us to do. It would be helpful to get a smaller repro case for issues like this—the file you link is more than a thousand lines long. That would make it easier for us to see if it's similar to a previously reported crash. |
Simple repro case: class somerandomclass:
# fmt: off
@test()
# fmt: on
def foo():
pass
def thisIsAFunction():
pass And this was the bad code in the 1000+ lines file: # fmt: off
@pytest.mark.parametrize("address", [
{}, # empty dict
"this is not a dict", # not a dict at all.
])
# fmt: on
def test_address_raises_exceptions(self, address, inboundshipments_api):
"""Empty address dict should raise MWSError."""
with pytest.raises(MWSError):
inboundshipments_api.set_ship_from_address(address)
# fmt: off
@pytest.mark.parametrize("address", [
# name missing
{"address_1": "500 Summat Cully Lane", "city": "Gilead"},
# address_1 missing
{"name": "Roland Deschain", "city": "Gilead"},
# city missing
{"name": "Roland Deschain", "address_1": "500 Summat Cully Lane"},
])
# fmt: on
def test_required_address_keys_missing(self, address, inboundshipments_api):
"""Any missing required key should raise MWSError"""
with pytest.raises(MWSError):
inboundshipments_api.set_ship_from_address(address) If you remove this chunk in the file, the file formats correctly and without error. The problem seems to be that the Doing a |
I was just about to mention that. Removing my Thanks @ichard26 ! |
Working on the tests in one of my projects, converting some from using
unittest
topytest
. While adding some fixtures and moving things around, Black reported it could no longer format one of the files.To Reproduce This commit contains the file
tests/apis/inboundshipments/test_requests.py
. Run Black with all default arguments, and see an error pop up.(direct link to the file in that commit)
Expected behavior No error, reformat or leave alone.
Environment (please complete the following information):
ubuntu-latest
and latest Py3 they have available. This workflow run shows the same error (the workflow code currently runspip install black
).Does this bug also happen on master? Checked with online formatter, and no, the same bug does not occur. Good to know!
Additional context Seems like a new release would fix it, or I could change our test suite and my local tools to target latest from your
master
branch. Any insight on exact cause of the problem would be good to know, so I can watch out for anything I may be introducing.Thank you.
The text was updated successfully, but these errors were encountered: