Skip to content

# fmt: skip is not being respected with one-liner functions #4535

Open
@polirritmico

Description

Describe the bug

Hi, # fmt: skip doesn't skip the formatting in this code:

def foo(): return "mock"  # fmt: skip
$ black foo.py; cat foo.py

Output:

def foo():
    return "mock"  # fmt: skip

Similar case in the playground.

Expected behavior

From the docs I understand that Black should not reformat lines that contain # fmt: skip (The basics -> Usage -> Ignoring sections).

Environment

  • Black's version: 24.10.0 (compiled: yes), 24.10.1.dev22+g6000d37 (compiled: no)
  • OS and Python version: Gentoo Linux 2.17, Python 3.12.8

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    F: fmtskipfmt: skip implementationT: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions