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:
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]"
Activity
erictraut commented on Aug 13, 2023
This is a duplicate of #8252.
This bug report is a simpler demonstration of the bug, so it might be worth keeping this one open and closing the other.
ichard26 commented on Aug 22, 2023
#8252, which I just closed, contains some more examples of this issue.
erictraut commented on Aug 22, 2023
I think this might also be the same as #15793.
Do not narrow types to Never with binder (python#18972)
Do not narrow types to Never with binder (#18972)