Incorrect type narrowing for isinstance when filter is a generic class with a type parameter that has a default
erictraut opened this issue · comments
Eric Traut commented
from typing import Generic
from typing_extensions import TypeVar
T = TypeVar("T", bound=int, default=int)
class Foo(Generic[T]): ...
def func(obj: object):
if isinstance(obj, Foo):
reveal_type(obj) # Should be Foo[Unknown], but is currently Foo[int]
Eric Traut commented
My first attempt at fixing this resulted in some apparent regressions that need to be investigated and addressed.
Eric Traut commented
This is addressed in pyright 1.1.363, which I just published.