basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

`reportUnreachable` and `reportUnnecessaryComparison` false positive when comparing `TypeForm` to `None`

Open DetachHead opened this issue 11 months ago • 1 comments

Description

Code sample in basedpyright playground

from typing_extensions import TypeForm


def foo(value: TypeForm[object]):
    if value is None: # error: reportUnnecessaryComparison
        print('hi') # error: reportUnreachable, reached at runtime

foo(None)

DetachHead avatar Apr 03 '25 01:04 DetachHead

same with NoneType except only reportUnreachable is reported but not reportUnnecessaryComparison

DetachHead avatar Apr 03 '25 01:04 DetachHead