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

remove HashableT in frame.pyi where possible #1104

Merged
merged 3 commits into from
Feb 4, 2025

Conversation

Dr-Irv
Copy link
Collaborator

@Dr-Irv Dr-Irv commented Jan 31, 2025

mypy has finally put in the feature allowing asymmetric getters/setters. During the testing, they had an issue with our stubs regarding where we use HashableT. See python/mypy#18510 (comment)

This fixes that issue. Then once mypy 1.16 i released, we can fix the tests for setting columns that have # type: ignore in it.

@Dr-Irv Dr-Irv requested a review from twoertwein January 31, 2025 15:38
@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Feb 1, 2025

@twoertwein I've addressed all your comments. I don't think any other changes are necessary. Let me know if you disagree.

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Feb 3, 2025

@twoertwein have updated with a test based on your finding.

@twoertwein
Copy link
Member

There are a few more of these cases - sorry, I was lazy and wrote quick tests for type checkers but they might fail at runtime. In all cases, the first one fails type checking whereas the second one passes:

import pandas as pd

df = pd.DataFrame([])
test = ["test"]

df.to_stata("test", convert_strl=test)
df.to_stata("test", convert_strl=["test"])

df.to_html("test", columns=test)
df.to_html("test", columns=["test"])

df.to_xml("test", attr_cols=test)
df.to_xml("test", attr_cols=["test"])

df.to_xml("test", elem_cols=test)
df.to_xml("test", elem_cols=["test"])

df.columns = test
df.columns = ["test"]

testDict = {"test": 1}
df.to_string("test", col_space=testDict)
df.to_string("test", col_space={"test": 1})

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Feb 4, 2025

There are a few more of these cases - sorry, I was lazy and wrote quick tests for type checkers but they might fail at runtime. In all cases, the first one fails type checking whereas the second one passes:

Thanks. Addressed in next commit. I added your code as a test (after making it work at runtime)

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Feb 4, 2025

@twoertwein ready for review again

@twoertwein twoertwein merged commit 54b15c3 into pandas-dev:main Feb 4, 2025
10 checks passed
@twoertwein
Copy link
Member

Thank you @Dr-Irv !

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.

None yet

2 participants