-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Labels
F: fmtskipfmt: skip implementationfmt: skip implementationT: bugSomething isn't workingSomething isn't working
Description
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 FalseExpected 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 FalseEnvironment
Arch Linux
black, 25.1.0 (compiled: no)
Python (CPython) 3.13.5
Metadata
Metadata
Assignees
Labels
F: fmtskipfmt: skip implementationfmt: skip implementationT: bugSomething isn't workingSomething isn't working