-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
896 dataframe from dict columns dtype args #897
896 dataframe from dict columns dtype args #897
Conversation
I have added in f760452 new test and overload to cover when |
Let me know when I should do another review. |
@Dr-Irv please proceed, tests on my computer just finished successfully |
pandas-stubs/core/frame.pyi
Outdated
@overload | ||
@classmethod | ||
def from_dict( | ||
cls, | ||
data: dict[Any, Any], | ||
orient: Literal["columns", "index", "tight"] = ..., | ||
dtype: _str = ..., | ||
columns: list[_str] = ..., | ||
orient: str, | ||
dtype: AstypeArg | None = ..., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be removed. We only want to match the first or second overload. This would match any string for orient
.
tests/test_frame.py
Outdated
# check when not using Literal | ||
orient_str = "index" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the change I suggested above to remove the orient: str
, the test below may fail. But that's OK - in this case the type checker isn't inferring that doing orient = "index"
matches Literal["index"]
. I'm pretty sure that pyright does that inference - not sure about mypy.
So if you make that change, and this test below fails, you can remove the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test does fail with mypy.
I'll revert my last commit to suppress the last overload and failing tests
This reverts commit f760452.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @mutricyl
test_frame.test_types_from_dict