-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
type annotation for Index/MultiIndex.names is incorrect #804
Comments
There are a few things going on here, and I don't think we can do much about them. First, from a static typing perspective, we can't track the type of Second, whether the underlying index is single-dimensional or a Finally, you reported a mypy error on your own code, but we'd prefer an example that is self-contained and can be run directly through the type checker. I'm going to close this, but am willing to reopen it if you can convince me otherwise. |
Isn't
|
@Dr-Irv , I've added a standalone sample demonstrating the issue. |
Output of
|
Thanks @tswast for the example. I will reopen. The property for
in two ways:
PR with tests welcome. |
using >>> df.index.names = [None]
>>> df.index.names
FrozenList([None])
>>> df.index.names = [1]
>>> df.index.names
FrozenList([1]) The pandas-internal annotations declare I couldn't find |
Actually I think the getter should also return |
Can you provide an example? This may be one of the cases where if we declare the |
My bad I did not try it at runtime and thought the type would carry over in the getter but indeed it is a FrozenList that gets returned, let me write a quick test to make sure but I believe you are correct! |
Added a PR to see it in action, there still seems to be an issue with the setter type not getting recognize ( |
Still waiting on |
Describe the bug
type annotation for Index/MultiIndex.names is incorrect
To Reproduce
pandas
example that is not properly checked by the stubs.mypy
orpyright
).mypy
bigframes/core/blocks.py:436: error: Incompatible types in assignment (expression has type "tuple[None]", variable has type "list[str]") [assignment]
Please complete the following information:
Distributor ID: Debian
Description: Debian GNU/Linux rodete
Release: n/a
Codename: rodete
pandas-stubs
pandas-stubs==2.0.3.230814Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: