Pyright: pandas droplevel

Created on 17 Jun 2020  路  2Comments  路  Source: microsoft/pyright

_edit:_
same for groupby and concat:
https://github.com/gokturksm/Fikirler/blob/master/so_6.py

Description
Pandas dataframe object unstacked, dropped NAs, and lastly dropped a level. Drop level returns a dataframe without the specified column level(s). This process has no problem but pyright says "Cannot access member "droplevel" for type "NoReturn" and "Member "droplevel" is unknownPyright (reportGeneralTypeIssues)". I don't exactly know why, so I'm opening this issue.

To Reproduce
https://github.com/gokturksm/Fikirler/blob/master/so_10.py#L27

Expected behavior
No problem would be produced by pyright.

Screenshots or Code
shared already

VS Code extension or command-line
extension

Additional context
disabled all other completion engines or python-related things.
"pyright.useLibraryCodeForTypes": true

addressed in next version bug

All 2 comments

Thanks for reporting the issue.

Pyright is able to extract some type information from the implementation, so this case should still work. The problem is that when Pyright infers the return type of dropna, it is included a NoReturn type in the union. The NoReturn type should be stripped out of any union that includes it. Once it's removed, this error goes away.

This fix will be in the next published version of Pyright.

This is now fixed in version 1.1.44, which I just published.

Was this page helpful?
0 / 5 - 0 ratings