Skip to content

Commit 3be58e6

Browse files
committed
refactor: try reusing Protocol's `Generic
- Didn't realise `3.8` had a `.__class_getitem__` - Possibly can replace `Protocol` w/ `Generic` in a `3.8` compat block - Provided this change doesn't break anything else
1 parent acd8cbf commit 3be58e6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

narwhals/_selectors.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from typing import Any
99
from typing import Callable
1010
from typing import Collection
11-
from typing import Generic
1211
from typing import Iterable
1312
from typing import Iterator
1413
from typing import Protocol
@@ -49,7 +48,7 @@
4948
EvalNames: TypeAlias = Callable[[FrameT], Sequence[str]]
5049

5150

52-
class CompliantSelectorNamespace(Generic[FrameT, SeriesT], Protocol):
51+
class CompliantSelectorNamespace(Protocol[FrameT, SeriesT]):
5352
_implementation: Implementation
5453
_backend_version: tuple[int, ...]
5554
_version: Version
@@ -159,7 +158,7 @@ def names(df: FrameT) -> Sequence[str]:
159158

160159

161160
class LazySelectorNamespace(
162-
CompliantSelectorNamespace[FrameT, SeriesT], Generic[FrameT, SeriesT], Protocol
161+
CompliantSelectorNamespace[FrameT, SeriesT], Protocol[FrameT, SeriesT]
163162
):
164163
def _iter_schema(self, df: FrameT) -> Iterator[tuple[str, DType]]:
165164
yield from df.schema.items()
@@ -168,9 +167,7 @@ def _iter_columns_dtypes(self, df: FrameT, /) -> Iterator[tuple[SeriesT, DType]]
168167
yield from zip(self._iter_columns(df), df.schema.values())
169168

170169

171-
class CompliantSelector(
172-
CompliantExpr[FrameT, SeriesT], Generic[FrameT, SeriesT], Protocol
173-
):
170+
class CompliantSelector(CompliantExpr[FrameT, SeriesT], Protocol[FrameT, SeriesT]):
174171
@property
175172
def selectors(self) -> CompliantSelectorNamespace[FrameT, SeriesT]:
176173
return self.__narwhals_namespace__().selectors

0 commit comments

Comments
 (0)