pyright icon indicating copy to clipboard operation
pyright copied to clipboard

reportUnusedVariable considers variable as used after reassignment

Open solutionseekeras opened this issue 6 months ago • 0 comments

Describe the bug

Pyright considers a variable to be used if it has been used at least once, even if it is later reassigned to without use.

Code or Screenshots


def f() -> None:
    a = 1

    # I would expect the left-hand side `a` to be flagged as unused here (PyCharm does so)
    a = 2 * a

# pyright: reportUnusedVariable=error

pyright <path-to-file> results in 0 errors, 0 warnings, 0 informations.

VS Code extension or command-line pyright 1.1.377 on the command-line.

solutionseekeras avatar Aug 22 '24 12:08 solutionseekeras