Pyright: __path__ is inferred an Iterable[str] rather than list

Created on 14 Sep 2020  路  2Comments  路  Source: microsoft/pyright

import packagename

path = packagename.__path__[0]

Errors with:

  3:8 - error: "__getitem__" method not defined on type "Iterable[str]" (reportGeneralTypeIssues)

However:

$ python
Python 3.6.9 (default, Nov 30 2019, 18:11:51) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import packagename
>>> type(packagename.__path__)
<class 'list'>
>>> 

pyright 1.1.70

addressed in next version bug

All 2 comments

Thanks for the bug report. The fix will be in the next release.

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

Was this page helpful?
0 / 5 - 0 ratings