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

Move F841 unused variable because not dummy syntax on preview into a specific rule #15418

Closed
un-pogaz opened this issue Jan 11, 2025 · 1 comment
Labels
question Asking for support or clarification rule Implementing or modifying a lint rule

Comments

@un-pogaz
Copy link

For this code:

def make_tuple(idx):
    return idx, str(idx)


def foo(count):
    for i in range(count):
        value, dummy = make_tuple(i)
        print(value)

When run Ruff in normal mode, return no error. But when run into preview mode, Ruff sudendly raise unused variable error because the dummy syntax is not used for the unpacking tuple, even if your use the explicit-preview-rules settings on true.

Except I don't want use dummy syntax. After having explored different options, settings and rules, I haven't found any solution that doesn't create more problems, and I'm obliged to ignore the rule 'F841' from the entire project (which is far from great, but clearly the lesser evil).

Excepted behavior:

Run Ruff in preview mode with explicit-preview-rules settings on true, the output should be identical to Ruff into normal mode.

Suggestion:

Create a specific (preview) rule to control and raise error if a unused variable should use dummy syntax instead.

This will make it possible to finely control Ruff's behavior, while preserving consistency output between normal and preview mode.

@dylwil3 dylwil3 added rule Implementing or modifying a lint rule preview Related to preview mode features labels Jan 11, 2025
@MichaReiser MichaReiser added question Asking for support or clarification and removed preview Related to preview mode features labels Jan 11, 2025
@MichaReiser
Copy link
Member

Hi @un-pogaz

It's currently not possible to only opt-in to preview behavior of some rules but not of others because it would require an explicit syntax in the configuration.

Splitting this rule has already been proposed in another issue. I'll merge the two

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for support or clarification rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

3 participants