Skip to content

black told me to report a bug for lines with # fmt: skip on them, I think #4873

@adiabatic

Description

@adiabatic

Describe the bug

black told me to report a bug:

~/.local/bin > black obsidian-preferences-please.py 
error: cannot format obsidian-preferences-please.py: INTERNAL ERROR: Black 25.11.0 on Python (CPython) 3.14.0 produced code that is not equivalent to the source.  Please report a bug on https://github.com/psf/black/issues.  This diff might be helpful: /var/folders/6d/wgwms3kx2zx782p82r8x6qdw0000gn/T/blk_dv1novq0.log

Oh no! 💥 💔 💥
1 file failed to reformat.

To Reproduce

Here’s the source (it’s not minimal, but it isn’t large, either):

#!/usr/bin/env python3
from pathlib import Path
from os.path import join
from json import dumps, loads


def update_hotkeys(path_string):
    p = Path(path_string)
    hotkeys = {
      "editor:swap-line-down": [{"key": "ArrowDown", "modifiers": ["Alt", "Mod"]}], # fmt: skip
      "editor:swap-line-up":   [{"key": "ArrowUp",   "modifiers": ["Alt", "Mod"]}], # fmt: skip
      "editor:toggle-source":  [{"key": "S",         "modifiers": ["Alt", "Mod"]}], # fmt: skip
    }
    for n in range(1, 6+1):
        hotkeys[f'editor:set-heading-{n}'] = [{"key": f"{n}", "modifiers": ["Alt", "Mod"]}]

    if p.exists():
        with p.open(mode='r', encoding='UTF-8') as f:
            s = f.read()
            if not s.strip(): s = "{}"
            existing_hotkeys = loads(s)
            hotkeys = {**existing_hotkeys, **hotkeys}

    with p.open(mode="w", encoding="UTF-8") as f:
        output = dumps(hotkeys, indent=2, sort_keys=True)
        f.write(output)

update_hotkeys(join(".obsidian", "hotkeys.json"))

def twiddle_core_plugins(path_string):
    p = Path(path_string)
    to_falsify = 'word-count daily-notes sync backlink properties'.split()
    if not p.exists():
        print(f"{path_string} does not exist. Not twiddling core plugins.")
        return

    s = p.read_text(encoding='UTF-8')
    if not s.strip(): s = "{}"
    existing_plugins = loads(s)
    for plugin in to_falsify:
        existing_plugins[plugin] = False

    p.write_text(
        dumps(existing_plugins, indent=2, ensure_ascii=False),
        encoding='UTF-8'

       )
            

twiddle_core_plugins(join(".obsidian", "core-plugins.json"))

As above, I ran:

black obsidian-preferences-please.py

The resulting error is:

error: cannot format obsidian-preferences-please.py: INTERNAL ERROR: Black 25.11.0 on Python (CPython) 3.14.0 produced code that is not equivalent to the source. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /var/folders/6d/wgwms3kx2zx782p82r8x6qdw0000gn/T/blk_dv1novq0.log

Oh no! 💥 💔 💥
1 file failed to reformat.

Expected behavior

I expected black to adjust my indentation or complain that I’d made a parse error somewhere.

Environment

  • Black's version: 25.11.0
  • OS and Python version: macOS 15.7.2 (Sequoia), Python 3.14.0, almost certainly provided by Homebrew (same thing for black itself)

Additional context

Here’s the diff in the log that was mentioned:

--- src
+++ dst
@@ -117,22 +117,10 @@
                     kind=
                     None,  # NoneType
                     value=
                     'editor:swap-line-down',  # str
                 )  # /Constant
-                Constant(
-                    kind=
-                    None,  # NoneType
-                    value=
-                    'editor:swap-line-up',  # str
-                )  # /Constant
-                Constant(
-                    kind=
-                    None,  # NoneType
-                    value=
-                    'editor:toggle-source',  # str
-                )  # /Constant
                 values=
                 List(
                     ctx=
                     Load(
                     )  # /Load
@@ -155,102 +143,10 @@
                         Constant(
                             kind=
                             None,  # NoneType
                             value=
                             'ArrowDown',  # str
-                        )  # /Constant
-                        List(
-                            ctx=
-                            Load(
-                            )  # /Load
-                            elts=
-                            Constant(
-                                kind=
-                                None,  # NoneType
-                                value=
-                                'Alt',  # str
-                            )  # /Constant
-                            Constant(
-                                kind=
-                                None,  # NoneType
-                                value=
-                                'Mod',  # str
-                            )  # /Constant
-                        )  # /List
-                    )  # /Dict
-                )  # /List
-                List(
-                    ctx=
-                    Load(
-                    )  # /Load
-                    elts=
-                    Dict(
-                        keys=
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'key',  # str
-                        )  # /Constant
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'modifiers',  # str
-                        )  # /Constant
-                        values=
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'ArrowUp',  # str
-                        )  # /Constant
-                        List(
-                            ctx=
-                            Load(
-                            )  # /Load
-                            elts=
-                            Constant(
-                                kind=
-                                None,  # NoneType
-                                value=
-                                'Alt',  # str
-                            )  # /Constant
-                            Constant(
-                                kind=
-                                None,  # NoneType
-                                value=
-                                'Mod',  # str
-                            )  # /Constant
-                        )  # /List
-                    )  # /Dict
-                )  # /List
-                List(
-                    ctx=
-                    Load(
-                    )  # /Load
-                    elts=
-                    Dict(
-                        keys=
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'key',  # str
-                        )  # /Constant
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'modifiers',  # str
-                        )  # /Constant
-                        values=
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'S',  # str
                         )  # /Constant
                         List(
                             ctx=
                             Load(
                             )  # /Load

I also got this log file for an earlier version of black that Visual Studio Code was choosing to use — Black 25.1.0 on Python (CPython) 3.14.0:

--- src
+++ dst
@@ -117,22 +117,10 @@
                     kind=
                     None,  # NoneType
                     value=
                     'editor:swap-line-down',  # str
                 )  # /Constant
-                Constant(
-                    kind=
-                    None,  # NoneType
-                    value=
-                    'editor:swap-line-up',  # str
-                )  # /Constant
-                Constant(
-                    kind=
-                    None,  # NoneType
-                    value=
-                    'editor:toggle-source',  # str
-                )  # /Constant
                 values=
                 List(
                     ctx=
                     Load(
                     )  # /Load
@@ -155,102 +143,10 @@
                         Constant(
                             kind=
                             None,  # NoneType
                             value=
                             'ArrowDown',  # str
-                        )  # /Constant
-                        List(
-                            ctx=
-                            Load(
-                            )  # /Load
-                            elts=
-                            Constant(
-                                kind=
-                                None,  # NoneType
-                                value=
-                                'Alt',  # str
-                            )  # /Constant
-                            Constant(
-                                kind=
-                                None,  # NoneType
-                                value=
-                                'Mod',  # str
-                            )  # /Constant
-                        )  # /List
-                    )  # /Dict
-                )  # /List
-                List(
-                    ctx=
-                    Load(
-                    )  # /Load
-                    elts=
-                    Dict(
-                        keys=
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'key',  # str
-                        )  # /Constant
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'modifiers',  # str
-                        )  # /Constant
-                        values=
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'ArrowUp',  # str
-                        )  # /Constant
-                        List(
-                            ctx=
-                            Load(
-                            )  # /Load
-                            elts=
-                            Constant(
-                                kind=
-                                None,  # NoneType
-                                value=
-                                'Alt',  # str
-                            )  # /Constant
-                            Constant(
-                                kind=
-                                None,  # NoneType
-                                value=
-                                'Mod',  # str
-                            )  # /Constant
-                        )  # /List
-                    )  # /Dict
-                )  # /List
-                List(
-                    ctx=
-                    Load(
-                    )  # /Load
-                    elts=
-                    Dict(
-                        keys=
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'key',  # str
-                        )  # /Constant
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'modifiers',  # str
-                        )  # /Constant
-                        values=
-                        Constant(
-                            kind=
-                            None,  # NoneType
-                            value=
-                            'S',  # str
                         )  # /Constant
                         List(
                             ctx=
                             Load(
                             )  # /Load

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: crashBlack is crashingF: fmtskipfmt: skip implementationT: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions