Type narrowing with isinstance()
doesn't work correctly for Union types
#8302
Labels
addressed in next version
Issue is fixed and will appear in next published version
bug
Something isn't working
Consider this code.
With pyright 1.1.370, this results in an error:
It looks like inside of the
if isinstance(x, Foo):
block, it is not narrowingx
toFoo
; it still thinks it could beFoo | list[Foo]
.If I change the definition of
Foo
so that it's justFoo = int
(and not a union type) then no error is reported.The text was updated successfully, but these errors were encountered: