-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
ENH: Forward operators to underlying types #820
Comments
This is a nice idea, but how you would handle the cases of |
Timestamp+Timedelta works, if I remove all the overloads but this one. Not sure why mypy/pyright are confused by that. With the overloads, both say there is no matching rule. Timedelta+Timestamp (the reverse) works without changes. I think mypy/pyright just pick the first overload ( Unrelated: _T being covariate might also cause troubles with how it would be used in the actual Series (the current TypeVar there is invariant). |
Closing, see microsoft/pyright#6549 (comment) It is said that there is no generic approach to forward type annotations from encapsulated types. It underminds the usefulness of the Series dtype a bit (will be lost with many operators). |
Describe the bug
Series is a container that forwards operators (+, -, ...) to the underlying types.
Some of the operators of Series could be better, for example,
__add__
which:Series[Unknown]
instead ofSeries[return type]
Instead of returning too wide types, enumerating all typing combinations, or creating non-existing helper classes, it might(?) be possible to abuse Protocols to forward operators to the underlying types.
To Reproduce
The following code works with both mypy and pyright
The text was updated successfully, but these errors were encountered: