-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
Unexpected, Misleading mypy Failures After pandas-stubs Update: DataFrame.from_dict() Behavior #928
Comments
Btw. the following example works, i.e. shows no issue: b = [
{"key1": "value1", "key2": 42},
{"key1": "value2", "key2": 123},
]
df = pd.DataFrame.from_dict(b) # type: ignore
i: int = df.shape[0] |
You wrote:
If I look at the docs https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.from_dict.html , it doesn't say that a list of |
Related to #929 . |
Sure! |
Created a pandas issue, see pandas-dev/pandas#58862. |
Describe the bug
The
DataFrame.from_dict()
method allows parsing lists of dictionaries, where each dictionary is interpreted as a single row. However, this behavior is not reflected in the typed method signatures coded in pandas-stubs. We use that behavior and add# type: ignore
comments to suppress mypy errors.This worked without issue up until pandas-stubs version 2.2.1.240316, but with the update to version 2.2.2.240514, it leads to unexpected mypy failures, see below. The specific change responsible might be this commit.
To Reproduce
pandas
example that is not properly checked by the stubs.mypy
orpyright
).mypy
Please complete the following information:
pandas-stubs
: 2.2.2.240514The text was updated successfully, but these errors were encountered: