Pyright: "Any" is unbound

Created on 22 Jul 2020  路  4Comments  路  Source: microsoft/pyright

from typing import Any, Union
from pandas import Index

S = Union['Index[Any]']

pyright 1.1.55 (no --lib option) fails with:

 4:18 - error: "Any" is unbound (reportUnboundVariable)

Python 3.6.10

addressed in next version bug

All 4 comments

Removing Any is my workaround for now.

Thanks for the bug report. This will be fixed in the next version of Pyright & Pylance.

If you do not need a forward reference here, you can remove the quotes as a workaround.

Removing the quotes works on the pyright CLI but gives me the following in VSCode:

Value 'Index' is unsubscriptable pylint(unsubscriptable-object)

I think this is because it's Python 3.6 without PEP 563 "postponed evaluations of type annotations"

This is addressed in Pyright 1.1.56, which I just published. It will also be in the next version of Pylance.

Was this page helpful?
0 / 5 - 0 ratings