-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
F: fmtofffmt: off implementationfmt: off implementationT: bugSomething isn't workingSomething isn't working
Description
Describe the bug
Black crashes when disabling fmt in some parts of the code
To Reproduce
For example, take this code:
class A:
async def call(param):
if param:
# fmt: off
if param[0:4] in (
"ABCD", "EFGH"
):
# fmt: on
return 1
elif param[0:4] in ("ZZZZ",):
return 2
elif param[0:4] in ("YYYY",):
return 3
return 4
If the fmt:off/on is moved to the elif, then it works:
class A:
async def call(param):
if param:
if param[0:4] in (
"ABCD", "EFGH"
):
return 1
# fmt: off
elif param[0:4] in (
"ZZZZ",
):
# fmt: on
return 2
elif param[0:4] in ("YYYY",):
return 3
return 4
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: /tmp/blk_ywpuqfap.log
Expected behavior
To format the code
Environment
Additional context
Metadata
Metadata
Assignees
Labels
F: fmtofffmt: off implementationfmt: off implementationT: bugSomething isn't workingSomething isn't working