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

GhH804 index names typehint #1031

Closed

Conversation

loicdiridollou
Copy link
Contributor

There remains the issue of mypy that complains once you set it as a tuple, it does not seem to recognize the expected type of the setter.

tests/test_indexes.py:1182: error: Incompatible types in assignment (expression has type "tuple[str]", variable has type "list[str | None]")  [assignment]
tests/test_indexes.py:1186: error: Incompatible types in assignment (expression has type "tuple[None]", variable has type "list[str | None]")  [assignment]

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 14, 2024

There remains the issue of mypy that complains once you set it as a tuple, it does not seem to recognize the expected type of the setter.

See python/mypy#3004 . Long standing issue (7+ years!!) in that mypy doesn't accept setters and getters on properties that have asymmetric arguments. Back in 2021, I was involved in a discussion on that issue with the pyright author and convinced him to support it.

So for this PR, I think you can just comment out the tests related to setting and getting tuples, and put a comment with a link to that mypy issue.

@loicdiridollou
Copy link
Contributor Author

Thanks @Dr-Irv for the insight, will close this one for now. I have added the reference you provided to the issue.

@loicdiridollou loicdiridollou deleted the gh804_index_names branch November 15, 2024 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

type annotation for Index/MultiIndex.names is incorrect
2 participants