Skip to content

Commit aca796a

Browse files
committed
chore(typing): Pragmatic solution for PolarsNamespace.selectors
See note on property for blockers
1 parent 7cd9ca7 commit aca796a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

narwhals/_polars/namespace.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Any
66
from typing import Iterable
77
from typing import Literal
8+
from typing import cast
89
from typing import overload
910

1011
import polars as pl
@@ -22,6 +23,7 @@
2223
from typing_extensions import Self
2324
from typing_extensions import TypeAlias
2425

26+
from narwhals._compliant import CompliantSelectorNamespace
2527
from narwhals._compliant import CompliantWhen
2628
from narwhals._polars.dataframe import Method
2729
from narwhals._polars.dataframe import PolarsDataFrame
@@ -204,9 +206,14 @@ def concat_str(
204206
backend_version=self._backend_version,
205207
)
206208

209+
# NOTE: Implementation is too different to annotate correctly (vs other `*SelectorNamespace`)
210+
# 1. Others have lots of private stuff for code reuse
211+
# i. None of that is useful here
212+
# 2. We don't have a `PolarsSelector` abstraction, and just use `PolarsExpr`
213+
# 3. `PolarsExpr` still has it's own gaps in the spec
207214
@property
208-
def selectors(self: Self) -> PolarsSelectorNamespace:
209-
return PolarsSelectorNamespace(self)
215+
def selectors(self: Self) -> CompliantSelectorNamespace[Any, Any]:
216+
return cast("CompliantSelectorNamespace[Any, Any]", PolarsSelectorNamespace(self))
210217

211218

212219
class PolarsSelectorNamespace:

0 commit comments

Comments
 (0)