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

F841 does not have branch analysis #16752

Open
sk- opened this issue Mar 14, 2025 · 1 comment
Open

F841 does not have branch analysis #16752

sk- opened this issue Mar 14, 2025 · 1 comment
Labels
rule Implementing or modifying a lint rule type-inference Requires more advanced type inference.

Comments

@sk-
Copy link

sk- commented Mar 14, 2025

Summary

F841 does not report variables that are unused in certain branches. Below is a short example (playground) showing the issue

def func(x):
    if x:
        io = ""
    else:
        io = "foo"
        print(io)   

This issue was originally reported to pyflakes and closed as duplicate of PyCQA/pyflakes#715.

They mention is unlikely they will implement branch analysis, but ruff already has (I guess) the machinery needed to support this use case.

Version

v0.11.0 (playground)

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule type-inference Requires more advanced type inference. labels Mar 14, 2025
@MichaReiser
Copy link
Member

MichaReiser commented Mar 14, 2025

They mention is unlikely they will implement branch analysis, but ruff already has (I guess) the machinery needed to support this use case.

Actually, Ruff doesn't have the machinery to support this, but we're working on it. But it's going to take a while to get ready for prime time ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule type-inference Requires more advanced type inference.
Projects
None yet
Development

No branches or pull requests

2 participants