- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.7k
 
Open
Labels
C: crashBlack is crashingBlack is crashingF: fmtskipfmt: skip implementationfmt: skip implementation
Description
Describe the bug
Black crashes on the following valid python code:
class ClassWithALongName:
    Constant1 = 1
    Constant2 = 2
    Constant3 = 3
def test():
    if (
        "cond1" == "cond1"
        and "cond2" == "cond2"
        and 1 in (
            ClassWithALongName.Constant1,
            ClassWithALongName.Constant2,
            ClassWithALongName.Constant3, # fmt: skip
        ) # fmt: skip
    ):
        return True
    return FalseTo Reproduce
Just run black on the given code.
The resulting error is:
error: cannot format temp.py: Cannot parse for target version Python 3.9: 15:5:     ): # fmt: skip
Oh no! 💥 💔 💥
1 file failed to reformat.
Environment
- Black's version: 
main - OS and Python version: Ubuntu 24.04 LTS, Python3.9 (tested on others on playground)
 
Additional context
- Crash is also observed when the second skip is on the previous line (L15)
 - Found it while looking into 
# fmt: skipignored inside multi-part if-clause #4730. Don't have a solution yet. 
Metadata
Metadata
Assignees
Labels
C: crashBlack is crashingBlack is crashingF: fmtskipfmt: skip implementationfmt: skip implementation