-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
MyPy doesn't recognize scalar arithmetic for pandas classes #31160
Comments
@WillAyd How can you ever know this "statically" ? |
It’s not the definition as much as the declaration. So something like add would have to exist statically for my py to recognize. right now we use factory methods at runtime to add that |
This comes up often enough i wouldn't mind changing our runtime-pinning to something like:
|
I don't mind adding these statically. I think talked with @jreback in the past though who may have disagreed so pinging for his input, otherwise would take a PR |
yeah ok with doing more static things as it will help with typing |
And apart from typing, it will also result in easier to understand code, I think |
the last part of #34869 (comment) is related
+1
+1 have started down this route on a few commonly used dynamically added methods, to avoid ignores. pandas/pandas/core/indexes/datetimes.py Lines 222 to 240 in 6648439
pandas/pandas/core/indexes/period.py Lines 150 to 158 in a0e0571
when I did the first one I thought it was clearer to include the actual code for clarity, but after adding a couple more, it does look more like boilerplate and @jbrockmendel solution may be better #31160 (comment) Will look again. |
Our arithmetic ops are no longer added dynamically. Does that solve this issue? |
Something like:
will yield
error: Unsupported operand types for + ("int" and "Series")
I assume because our arithmetic ops are added at runtime and not statically. Would be nice to support this somehow thoughThe text was updated successfully, but these errors were encountered: