Skip to content

Black is not honoring fmt: off for comment changes #3537

@nijel

Description

@nijel

Describe the bug

black since 23.1.0 breaks Munin magic markers without a way to override.

To Reproduce

For example, take this code:

# fmt: off
#%# family=auto
#%# capabilities=autoconf
# fmt: on

And run it with these arguments:

$ black file.py

The resulting output is:

# fmt: off
# %# family=auto
# %# capabilities=autoconf
# fmt: on

Expected behavior

The block between fmt: off and fmt: on should not be changed.

Environment

  • Black's version: 23.1.0
  • OS and Python version: Linux/Python 3.11

Additional context

Seem to be related to #2919, it might be a separate bug there as well, as it talks only about #%% (note the double %). So, it might be two bugs here:

  • fmt: off not honored
  • #%% formatting being actually applied to #%

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: fmtofffmt: off implementationT: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions