chore(typing): Generic CompliantDataFrame#2115
Conversation
- Originally in #2064 - Will eventually support #2104 (comment)
- Now for `PolarsDataFrame` to be compliant, `PolarsSeries.alias` needs to be present - Since `PolarsDataFrame` can be returned in all of these places, they all required the update to `_polars`
Originally c11dc95
| @property | ||
| def columns(self) -> Sequence[str]: ... | ||
| def get_column(self, name: str) -> CompliantSeriesT_co: ... |
There was a problem hiding this comment.
@MarcoGorelli I chose get_column just to provide a method that uses CompliantSeriesT_co.
The eventual goal will be (#2104 (comment))
| ) | ||
|
|
||
| def aggregate(self: Self, *exprs: ArrowExpr) -> Self: | ||
| def aggregate(self: ArrowDataFrame, *exprs: ArrowExpr) -> ArrowDataFrame: |
There was a problem hiding this comment.
why does this need changing?
There was a problem hiding this comment.
@MarcoGorelli
pyright is fine with Self IIRC - but mypy still needs all the extra inline annotations that we have on main
narwhals/narwhals/_arrow/dataframe.py
Lines 357 to 374 in dc9fcaa
I had a tough time with that as well in (#2055) - where I've tried moving it into a method:
narwhals/narwhals/_protocols.py
Lines 50 to 87 in 35cef0b
There was a problem hiding this comment.
This was the log from (c11dc95)
narwhals/_arrow/dataframe.py:350: error: Cannot infer type argument 1 of
"evaluate_into_exprs" [misc]
new_series: Sequence[ArrowSeries] = evaluate_into_exprs(self, ...
^~~~~~~~~~~~~~~~~~~~~~~~~~...
narwhals/_arrow/dataframe.py:363: error: Cannot infer type argument 1 of
"evaluate_into_exprs" [misc]
new_columns: list[ArrowSeries] = evaluate_into_exprs(self, *ex...
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
narwhals/_arrow/dataframe.py:548: error: Cannot infer type argument 1 of
"evaluate_into_exprs" [misc]
mask_native = evaluate_into_exprs(self, predicate)[0]._nat...
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
narwhals/_pandas_like/dataframe.py:395: error: Cannot infer type argument 1 of
"evaluate_into_exprs" [misc]
new_series: list[PandasLikeSeries] = evaluate_into_exprs(self,...
^~~~~~~~~~~~~~~~~~~~~~~~~...
narwhals/_pandas_like/dataframe.py:445: error: Cannot infer type argument 1 of
"evaluate_into_exprs" [misc]
mask = evaluate_into_exprs(self, predicate)[0]
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
narwhals/_pandas_like/dataframe.py:454: error: Cannot infer type argument 1 of
"evaluate_into_exprs" [misc]
new_columns: list[PandasLikeSeries] = evaluate_into_exprs(self...
^~~~~~~~~~~~~~~~~~~~~~~~...
MarcoGorelli
left a comment
There was a problem hiding this comment.
well done @dangotbanned , thanks for improving Narwhals!

What type of PR is this? (check all applicable)
Related issues
CompliantSelector#2064)mypyerrors fixed in (c11dc95)DataFrame.iter_columns#2104 (comment))Checklist
If you have comments or can explain your changes, please do so below