Skip to content

black==25.11.0 removing %% [markdown] comments #4843

@jamesbraza

Description

@jamesbraza

Describe the bug

As of black==25.11.0 but not in black==25.9.0, it's removing extra code comments.

To Reproduce

Run black a.py on the below:

# %% [markdown]

# fmt: off
# fmt: on

It overzealously removes the top comment, leaving just:

# fmt: off
# fmt: on

Expected behavior

black to not remove the header comments, as they're part of Jupytext's percent format.

Environment

  • Black's version: 25.11.0 (and current main branch at black==25.11.1.dev3+gf209c53a0)
  • OS: macOS 15.6.1, build version 24G90
  • Python version: Python 3.13.5 (main, Jul 10 2025, 15:26:00) [Clang 17.0.0 (clang-1700.0.13.5)]

Additional context

Coming from mwouts/jupytext#1467 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions