Bug Report
Accessing a variable of a generic type after an if isinstance() against a (non-generic) subclass of said type changes the variable's type to <nothing> within the isinstance clause scope:
fromtypingimportList, TypeVarclassIntList(List[int]):
passT=TypeVar("T")
deff(s: List[T]) ->T:
reveal_type(s)
ifisinstance(s, IntList):
reveal_type(s)
s.pop()
reveal_type(s)
returns.pop()Expected Behavior
No error.
Actual Behavior
note: Revealed type is "builtins.list[T`-1]"
note: Revealed type is "<nothing>"
error: <nothing> has no attribute "pop" [attr-defined]
note: Revealed type is "builtins.list[T`-1]"
Your Environment
Bug Report
Accessing a variable of a generic type after an
if isinstance()against a (non-generic) subclass of said type changes the variable's type to<nothing>within theisinstanceclause scope:Expected Behavior
No error.
Actual Behavior
Your Environment