psf / black

The uncompromising Python code formatter
https://black.readthedocs.io/en/stable/
MIT License
37.82k stars 2.4k forks source link

INTERNAL ERROR while formatting (log included) #4396

Closed teverus closed 2 days ago

teverus commented 3 days ago

Describe the bug

I was formatting my code when an error broke. The console said that I needed to report it, so here I am

To Reproduce

blk_zse1vd0s.log I have no idea how to reproduce it, but I'll attach a log file.

The resulting error is:

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: C:\Users\XXX\AppData\Local\Temp\blk_zse1vd0s.log

Expected behavior

Not this...

Environment

Additional context

Good luck and thank you :)

teverus commented 3 days ago

I fixed it manually :(

    SSO_STG_AUTH_URL = "XXX"  # fmt: skip

    data = {
        "username": get_from_vault_with_fallback("Hello", ENV_VARS.SCYLLA_TEST_USERNAME),  # fmt: skip
        "password": get_from_vault_with_fallback("Hello", ENV_VARS.SCYLLA_TEST_PASSWORD),  # fmt: skip
        "client_secret": get_from_vault_with_fallback("Hello", ENV_VARS.SCYLLA_TEST_CLIENT_SECRET),  # fmt: skip
        "client_id": "XXX",
        "grant_type": "password",
    }

to

    # fmt: off
    SSO_STG_AUTH_URL = "XXX"

    data = {
        "username": get_from_vault_with_fallback("Hello", ENV_VARS.SCYLLA_TEST_USERNAME),
        "password": get_from_vault_with_fallback("Hello", ENV_VARS.SCYLLA_TEST_PASSWORD),
        "client_secret": get_from_vault_with_fallback("Hello", ENV_VARS.SCYLLA_TEST_CLIENT_SECRET),
        "client_id": "XXX",
        "grant_type": "password",
    }
    # fmt: on

It's not much, but it's honest work :)

I think the problem was that I used too many # fmt: skip

MeGaGiGaGon commented 2 days ago

Looks to be a duplicate of #3608, just using a dict instead of parentheses to make the expression. Minimum reproduction: playground link