basedpyright icon indicating copy to clipboard operation
basedpyright copied to clipboard

support narrowing on `a is b` where `b` is a generic

Open DetachHead opened this issue 10 months ago • 1 comments

Description

Code sample in basedpyright playground

def foo[T](a: object, b: T) -> T:
    assert a is b
    return a # error: Type "object" is not assignable to type "T@foo"

doesn't look like this is in the list of supported type guards but i think it should be supported. i also couldn't find an upstream issue but i'm certain this has been raised and rejected already

DetachHead avatar Apr 24 '25 02:04 DetachHead

related: #391

DetachHead avatar Apr 24 '25 03:04 DetachHead