Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pandas: false positive with a multi-index #850

Closed
thierry-bm opened this issue Jan 18, 2021 · 3 comments
Closed

pandas: false positive with a multi-index #850

thierry-bm opened this issue Jan 18, 2021 · 3 comments
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version typestub Issue relating to our bundled type stubs

Comments

@thierry-bm
Copy link

thierry-bm commented Jan 18, 2021

Environment data

  • Language Server version: 2021.1.1
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.3

Expected behaviour

No false positive.

Actual behaviour

False positive on the following piece of code :

midx = pd.MultiIndex.from_product([["A0", "A1"], ["B0", "B1", "B2", "B3"]])
t = pd.DataFrame(np.arange(16).reshape((2, len(midx))), index=['a','b'], columns=midx)
t[('A0','B0')]

The last line is reported as an error : No overloads for "t[('A0', 'B0')]" match parameters Calling function "__getitem__" Argument types: (tuple[Literal['A0'], Literal['B0']])

I think Pylance doesn't understand correctly that tuples can be used in a multiindex settings?

I can provide logs if needed. Thanks for this great extension!

@judej judej added the typestub Issue relating to our bundled type stubs label Jan 19, 2021
@github-actions github-actions bot removed the triage label Jan 19, 2021
@jakebailey jakebailey added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Mar 13, 2021
@jakebailey jakebailey changed the title Pandas false positive with a multi-index pandas: false positive with a multi-index Mar 17, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.3.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202132-17-march-2021

@thierry-bm
Copy link
Author

Awesome. Concerning Pandas I still notice typing bugs almost daily (although it's probably the same ones that keep coming back), is it something that is worth reporting in this repo? I was under the impression that the pandas team was also working on improved "official" typing stubs. Does this kind of fix suppose to act as a temporary solution ?

@jakebailey
Copy link
Member

Yes, still report them. We push these changes back to the https://github.com/microsoft/python-type-stubs repo which they will likely pull from (and we deprecate), but that process is slow going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in next version (main) A fix has been implemented and will appear in an upcoming version typestub Issue relating to our bundled type stubs
Projects
None yet
Development

No branches or pull requests

3 participants