Skip to content

# fmt: skip regression #5112

@pekkaklarck

Description

@pekkaklarck

Describe the bug

# fmt: skip is not handled properly in all cases with black 26.1 and newer.

To Reproduce

Our project has this code:

class Body(model.BaseBody[
    "Keyword", "For", "While", "Group", "If", "Try", "Var", "Return", "Continue",
    "Break", "model.Message", "Error"
]):  # fmt: skip
    __slots__ = ()

Older black versions have left that alone as expected, but starting from black 26.1 the result is this:

class Body(model.BaseBody["Keyword", "For", "While", "Group", "If", "Try", "Var", "Return", "Continue", "Break", "model.Message", "Error"]):  # fmt: skip
    __slots__ = ()

Expected behavior

I'd expect the code not to be touched as earlier.

Environment

  • Black's version: 26.1 - 26.3.2.dev31+g8dcc4865c
  • OS and Python version: Linux, Python 3.13

Additional context

Other # fmt: skip usages seem to work fine also with new black versions. For example, we have the following code right above the earlier example and it is not modified:

BodyItemParent = Union[
    "TestSuite", "TestCase", "UserKeyword", "For", "While", "If", "IfBranch",
    "Try", "TryBranch", "Group", None
]  # fmt: skip

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions