-
-
Notifications
You must be signed in to change notification settings - Fork 157
TYP: DataFrame.__setitem__ with None
#1550
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
base: main
Are you sure you want to change the base?
Conversation
6f392cb to
746c760
Compare
| df.loc[:, ["x"]] = [[None], [pd.NA], [pd.NaT]] # type: ignore[assignment,index] | ||
| df.iloc[:, [0]] = [[None], [pd.NA], [pd.NaT]] # type: ignore[assignment,index] | ||
|
|
||
| df.loc[:, iter(["x"])] = [[None], [pd.NA], [pd.NaT]] # type: ignore[assignment,index] | ||
| df.iloc[:, iter([0])] = [[None], [pd.NA], [pd.NaT]] # type: ignore[assignment,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.
Not too sure why they don't work for mypy
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.
@Dr-Irv any insights on this one? I tried and got the same error.
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.
It's a mypy bug and a difference between the pyright setting of strictListInference, which we have turned on because we are using pyright in strict mode.
I created python/mypy#20420
Can you add a comment referring to the above issue for those tests?
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.
| df[["col1"]] = [[None], [pd.NA]] # type: ignore[assignment,list-item] | ||
| df[iter(["col1"])] = [[None], [pd.NA]] # type: ignore[assignment] |
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.
Not too sure why they don't work for mypy
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.
loicdiridollou
left a comment
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.
Will approve preemptively, just one question for @Dr-Irv and then we should be good.
|
@loicdiridollou do you think the PR is good to merge? Also it would be good if we can make a new version after this PR, since we'll have all the regressions fixed, cc @Dr-Irv, thanks. |
__setitem__should accept sequences containing None? #1538assert_type()to assert the type of any return value)AGENTS.md.