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

RUF028 claims fmt: off invalid in else: block #10181

Closed
mrcljx opened this issue Mar 1, 2024 · 3 comments
Closed

RUF028 claims fmt: off invalid in else: block #10181

mrcljx opened this issue Mar 1, 2024 · 3 comments
Assignees
Labels
bug Something isn't working rule Implementing or modifying a lint rule

Comments

@mrcljx
Copy link

mrcljx commented Mar 1, 2024

RUF028 claims that the second fmt: off is illegal (the first one is fine). Both are actually respected by the formatter though.

Expecation: RUF028 should not trigger.

def f(a, b):
    if not a:
        # fmt: off
        a = b or bytes(
            [
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
            ]
        )
    else:
        # fmt: off
        a = b or bytes(
            [
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
            ]
        )

CleanShot 2024-03-01 at 11 00 00

https://play.ruff.rs/719df52a-6744-4230-8cf8-ed64a512143c

Ruff: 0.3.0

@MichaReiser
Copy link
Member

Thanks for reporting. That's a bug. I think #10178 fixed it but I let @snowsignal confirm

@MichaReiser MichaReiser added bug Something isn't working rule Implementing or modifying a lint rule labels Mar 1, 2024
@mrcljx
Copy link
Author

mrcljx commented Mar 1, 2024

Ah, nice. I only saw the title of the issue and not the PR summary that suggests this was fixed indeed.

@snowsignal
Copy link
Contributor

This should be fixed by #10178 in the next release. I confirmed that your code passes without issue on the latest version of the Ruff playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

3 participants