-
Notifications
You must be signed in to change notification settings - Fork 147
chore: refactor EagerWhen._if_then_else
#2662
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
chore: refactor EagerWhen._if_then_else
#2662
Conversation
) -> EagerWhen[EagerDataFrameT, EagerSeriesT, EagerExprT, NativeSeriesT]: ... | ||
) -> EagerWhen[EagerDataFrameT, EagerSeriesT, EagerExprT]: ... |
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.
I'm struggling to follow this
If I remove NativeSeriesT
from EagerWhen
, and hence from the return type, then mypy
/ pyright
tell me:
/home/runner/work/narwhals/narwhals/narwhals/_compliant/namespace.py:133:7 - warning: Type variable "NativeSeriesT" used in generic Protocol "EagerNamespace" should be covariant (reportInvalidTypeVarUse)
But, I can't make it covariant, because it's used as an argument to from_native
. If I did, type checkers would complain. I can't tell what they're expecting me to do π
@dangotbanned sorry for the ping, any tips would be appreciated π
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.
Hey @MarcoGorelli, I'll try to take a look at this today π
Would you be able to give some more background on what you're trying to accomplish with this PR please?
I'm not following the motivation from either the title or commit messages π€
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.
sure, it's to enable #2652 and #2645
i spent about 2 hours trying different things and wasn't able to get anywhere with this π³ , based on #2662 (comment) it looks to me like there were already issues with these protocols. happy for some parts to be brought back, so long as we're able to move towards the linked issues
I think we may just need to remove One trick could be to add |
@overload | ||
def from_native(self, data: NativeFrameT, /) -> EagerDataFrameT: ... | ||
@overload | ||
def from_native(self, data: NativeSeriesT, /) -> EagerSeriesT: ... | ||
# TODO @dangotbanned: Align `PandasLike` typing with `_namespace`, then drop this `@overload` | ||
# - Using the guards there introduces `_NativeModin`, `_NativeCuDF` | ||
# - These types haven't been integrated into the backend | ||
# - Most of the `pandas` stuff is still untyped | ||
@overload | ||
def from_native( | ||
self, data: NativeFrameT | NativeSeriesT | Any, / | ||
) -> EagerDataFrameT | EagerSeriesT: ... | ||
def from_native( | ||
self, data: NativeFrameT | NativeSeriesT | Any, / | ||
) -> EagerDataFrameT | EagerSeriesT: |
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.
I don't think this should have been merged
def _gather(self, rows: SizedMultiIndexSelector[Any]) -> Self: ... | ||
def _gather_slice(self, rows: _SliceIndex | range) -> Self: ... | ||
def _select_multi_index( | ||
self, columns: SizedMultiIndexSelector[NativeSeriesT] | ||
) -> Self: ... | ||
def _select_multi_name( | ||
self, columns: SizedMultiNameSelector[NativeSeriesT] | ||
) -> Self: ... | ||
def _select_multi_index(self, columns: SizedMultiIndexSelector[Any]) -> Self: ... | ||
def _select_multi_name(self, columns: SizedMultiNameSelector[Any]) -> Self: ... | ||
def _select_slice_index(self, columns: _SliceIndex | range) -> Self: ... |
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.
Yeah can you revert this PR?
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.
A refactor on when
shouldn't have to remove typing from other parts of narwhals
What type of PR is this? (check all applicable)
Related issues
Checklist
If you have comments or can explain your changes, please do so below