Code Monkey home page Code Monkey logo

Comments (8)

m-czernek avatar m-czernek commented on June 8, 2024

In fact, the # fmt: skip comment seems not to be honored at all?

For example, black still modifies client = billingdataservice.app.test_client() # fmt: skip -> client = billingdataservice.app.test_client() # fmt: skip (note added space before the # character)

Is that expected behavior?

from black.

m-czernek avatar m-czernek commented on June 8, 2024

Simplest reproducer:

$ black -c "test # fmt:skip"
test  # fmt:skip
$ black -c "test # fmt: skip"
test  # fmt: skip
$ black --preview -c "test # fmt: skip"
test  # fmt: skip
$ black --preview -c "test # fmt:skip"
test  # fmt:skip

Despite a line that contains fmt: skip comment, that line is modified by Black (always added a space before the # symbol). Not sure if I'm missing some flag or configuration.

from black.

JelleZijlstra avatar JelleZijlstra commented on June 8, 2024

I can't reproduce much of what you're reporting. You may be running a different version of Black than you think you're running.

% black -c "1+1 # fmt:skip; some other comment"          
1+1  # fmt:skip; some other comment
% black -c '''def client():
    client = billingdataservice.app.test_client() # fmt: skip; pylint: disable=redefined-outer-name
'''
def client():
    client = billingdataservice.app.test_client()  # fmt: skip; pylint: disable=redefined-outer-name
% black --version                                       
black, 23.12.1 (compiled: yes)
Python (CPython) 3.11.1

from black.

m-czernek avatar m-czernek commented on June 8, 2024

Hmm, this is strange. The above output is from Black I have installed by using pip install black.

I have reproduced the issue on the container we have in the repo, which I locally built with the black-container name:

podman run --rm black-container:latest black -c "test # fmt:skip"
test  # fmt:skip
$ podman run --rm black-container:latest black -c '''def client():
>     client = billingdataservice.app.test_client() # fmt: skip; pylint: disable=redefined-outer-name
> '''
def client():
    client = (
        billingdataservice.app.test_client()
    )  # fmt: skip; pylint: disable=redefined-outer-name

Similarly, I can do the same on Fedora (a different computer) when installing Black directly from Github:

$ black -c '''def client():
    client = billingdataservice.app.test_client() # fmt: skip; pylint: disable=redefined-outer-name
'''
def client():
    client = (
        billingdataservice.app.test_client()
    )  # fmt: skip; pylint: disable=redefined-outer-name

$ black --version
black, 23.12.2.dev13+ge11eaf2 (compiled: no)
Python (CPython) 3.12.1

I am a bit stumped as to what could be the discrepancy here...

from black.

hauntsaninja avatar hauntsaninja commented on June 8, 2024

@m-czernek the fix is only in the preview style (although I think technically it would have met the stability policy).

That is, your examples are fixed if you use --preview. I bet @JelleZijlstra is just working in a codebase where he has preview style in his config.

(We're also at the time of year where we cut preview style over to stable, so follow on at #4042 if you're interested)

from black.

m-czernek avatar m-czernek commented on June 8, 2024

@hauntsaninja I'm not sure you understand the issue. The examples seems not to be fixed by using --preview flag, for example using the container on your main:

podman run --rm black-container:latest black --preview -c "test # fmt:skip"
test  # fmt:skip

In other words, the # fmt:skip functionality seems to me not to work regardless of the --preview flag.

from black.

hauntsaninja avatar hauntsaninja commented on June 8, 2024

Okay, apologies, I was looking too much at #4143 (comment) / mention of #3959

IIUC the only issue remaining in preview is that Black normalises the whitespace before # fmt: skip (it does this on stable as well). This is regardless of whether there are other comments present on the line or not.

Does that sound right to you? (I've renamed the issue, but will rename again if there's something else as well)

from black.

RedGuy12 avatar RedGuy12 commented on June 8, 2024

See also #2970 (review)

from black.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.