Skip to content

Commit 6a39d56

Browse files
committed
try Protocol38 on EagerSeriesNamespace only
- Regular `Protocol` failed on `3.8`, `3.9`, `3.10` - (f4c0cd6) - Testing if I need on **every** protocol, or just the one with an `__init__`
1 parent 1321d94 commit 6a39d56

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

narwhals/_compliant/series.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import sys
34
from typing import TYPE_CHECKING
45
from typing import Any
56
from typing import Iterable
@@ -21,6 +22,16 @@
2122
from narwhals.utils import _SeriesNamespace
2223
from narwhals.utils import unstable
2324

25+
if not TYPE_CHECKING: # pragma: no cover
26+
if sys.version_info >= (3, 9):
27+
from typing import Protocol as Protocol38
28+
else:
29+
from typing import Generic as Protocol38
30+
else: # pragma: no cover
31+
# TODO @dangotbanned: Remove after dropping `3.8` (#2084)
32+
# - https://github.com/narwhals-dev/narwhals/pull/2064#discussion_r1965921386
33+
from typing import Protocol as Protocol38
34+
2435
if TYPE_CHECKING:
2536
from types import ModuleType
2637

@@ -306,7 +317,7 @@ def struct(self) -> Any: ...
306317

307318
class EagerSeriesNamespace( # type: ignore[misc]
308319
_SeriesNamespace[EagerSeriesT_co, NativeSeriesT_co],
309-
Protocol[EagerSeriesT_co, NativeSeriesT_co],
320+
Protocol38[EagerSeriesT_co, NativeSeriesT_co],
310321
):
311322
_compliant_series: EagerSeriesT_co
312323

0 commit comments

Comments
 (0)