Skip to content

Commit b192deb

Browse files
committed
fix(DRAFT): try removing Protocol altogether?
#2064 (comment)
1 parent d57c877 commit b192deb

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

narwhals/_selectors.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from typing import Collection
1111
from typing import Iterable
1212
from typing import Iterator
13-
from typing import Protocol
1413
from typing import Sequence
1514
from typing import TypeVar
1615
from typing import overload
@@ -23,6 +22,18 @@
2322
from narwhals.utils import is_compliant_dataframe
2423
from narwhals.utils import is_tracks_depth
2524

25+
if not TYPE_CHECKING:
26+
import sys
27+
28+
if sys.version_info >= (3, 9):
29+
from typing import Protocol
30+
else:
31+
from typing import Generic
32+
33+
Protocol = Generic
34+
else:
35+
from typing import Protocol
36+
2637
if TYPE_CHECKING:
2738
from datetime import timezone
2839

narwhals/typing.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@
55
from typing import Callable
66
from typing import Generic
77
from typing import Literal
8-
from typing import Protocol
98
from typing import Sequence
109
from typing import TypeVar
1110
from typing import Union
1211

12+
if not TYPE_CHECKING:
13+
import sys
14+
15+
if sys.version_info >= (3, 9):
16+
from typing import Protocol
17+
else:
18+
from typing import Generic
19+
20+
Protocol = Generic
21+
else:
22+
from typing import Protocol
23+
1324
if TYPE_CHECKING:
1425
from types import ModuleType
1526
from typing import Mapping

0 commit comments

Comments
 (0)