basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

unused variable/parameter false negative when it's reassigned before it's used

Open KotlinIsland opened this issue 1 year ago • 3 comments

def f(a: int):  # no nerror
   a = 1
   print(a)

https://basedpyright.com/?typeCheckingMode=all&code=CYUwZgBGAUCGBcUA2B7WAXAlPAUBfEsEAvBAIx4EAOATgJYB26cmQA

and

def f():
    a = 1  # no error
    a = 2

KotlinIsland avatar Sep 06 '24 11:09 KotlinIsland

huh???? it's literally used

DetachHead avatar Sep 06 '24 15:09 DetachHead

fail, it's reassigned first, the passed value is never used

KotlinIsland avatar Sep 06 '24 23:09 KotlinIsland

oh, that's the same with unused variables too. https://github.com/microsoft/pyright/issues/8806

DetachHead avatar Sep 07 '24 00:09 DetachHead