Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
polirritmico opened this issue Dec 21, 2024 · 4 comments · May be fixed by #4552
Open

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

polirritmico opened this issue Dec 21, 2024 · 4 comments · May be fixed by #4552
Labels
F: fmtskip fmt: skip implementation T: bug Something isn't working

Comments

@polirritmico
Copy link

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!

@polirritmico polirritmico added the T: bug Something isn't working label Dec 21, 2024
@JelleZijlstra JelleZijlstra added the F: fmtskip fmt: skip implementation label Dec 21, 2024
@FARDEEN-785
Copy link

Hey

I tried to run the code
The output:

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

Its seems that the #fmt: skip is not behaving as expected
Its the bug in Black ,is there anything to resolve this bug
Is there anything to fix this bug

Thanks
Fardeen khan

Pedro-Muller29 added a commit to Pedro-Muller29/black that referenced this issue Jan 18, 2025
Pedro-Muller29 added a commit to Pedro-Muller29/black that referenced this issue Jan 18, 2025
Pedro-Muller29 added a commit to Pedro-Muller29/black that referenced this issue Jan 18, 2025
Pedro-Muller29 added a commit to Pedro-Muller29/black that referenced this issue Jan 20, 2025
@saksham-sak

This comment has been minimized.

@polirritmico
Copy link
Author

polirritmico commented Jan 30, 2025

@saksham-sak, this issue is about # fmt: skip not respecting the documented behaviour.

@JelleZijlstra
Copy link
Collaborator

@saksham-sak you appear to be posting LLM-generated responses to a number of issues. It's not useful; please stop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: fmtskip fmt: skip implementation T: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants