pyright
pyright copied to clipboard
type from type checker is different to the type displayed on hover
Describe the bug i have no idea what's going on here, i tried to minify it as best as i can. it seems that the type displayed in pyright's errors/notes here is different to the type that normally appears when you hover over the variable, even though they're both coming from pyright's language server.
Code or Screenshots
foo = None
bar = False
for _ in []:
if not bar:
continue
if foo:
reveal_type(foo) # reveal_type says int, vscode says Never
baz = int(foo)
foo = baz
baz.asdf()
VS Code extension or command-line pyright vscode extension v1.1.353
i've disabled pylance and do not have any other extensions for python type checking installed, so this hover type is definitely coming from pyright as far as i'm aware
I'm able to repro the problem, and I agree it's a bug. Type should be the same regardless of evaluation order, but there appears to be a bug that causes evaluation-order-dependent results in this case. I'll investigate further.
This is addressed in pyright 1.1.364.