Describe the bug
#fmt: skip is ignored in the specific case demonstrated below.
Edit: Actually, thinking about it again I realised that (to me), the actual bug is that black changes the code at all. However, I'd already be happy if I could at least keep it from disfiguring my code via fmt: skip.
To Reproduce
Let black format this piece of code:
class ClassWithALongName:
Constant1 = 1
Constant2 = 2
Constant3 = 3
def test():
if (
"cond1" == "cond1"
and "cond2" == "cond2"
and 1 in ( # fmt: skip
ClassWithALongName.Constant1,
ClassWithALongName.Constant2,
ClassWithALongName.Constant3,
)
):
return True
return False
Expected behavior
Leave the line marked with # fmt: skip unchanged.
Instead, it moves the in to the next line, which I find confusing and hard to read:
def test():
if (
"cond1" == "cond1"
and "cond2" == "cond2"
and 1
in ( # fmt: skip
ClassWithALongName.Constant1,
ClassWithALongName.Constant2,
ClassWithALongName.Constant3,
)
):
return True
return False
Environment
Arch Linux
black, 25.1.0 (compiled: no)
Python (CPython) 3.13.5
Describe the bug
#fmt: skipis ignored in the specific case demonstrated below.Edit: Actually, thinking about it again I realised that (to me), the actual bug is that black changes the code at all. However, I'd already be happy if I could at least keep it from disfiguring my code via
fmt: skip.To Reproduce
Let black format this piece of code:
Expected behavior
Leave the line marked with
# fmt: skipunchanged.Instead, it moves the
into the next line, which I find confusing and hard to read:Environment
Arch Linux
black, 25.1.0 (compiled: no)
Python (CPython) 3.13.5