File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 66from typing import Mapping
77from typing import Protocol
88
9+ _MIN_TYPING_EXTENSIONS = 4 , 4 , 0
10+ _TYPING_EXTENSIONS = "typing_extensions"
11+
12+
13+ def _typing_extensions_has_pep_696 () -> bool : # pragma: no cover
14+ from importlib .metadata import version
15+ from importlib .util import find_spec
16+
17+ from narwhals .utils import parse_version
18+
19+ if find_spec (_TYPING_EXTENSIONS ):
20+ return parse_version (version (_TYPING_EXTENSIONS )) >= _MIN_TYPING_EXTENSIONS
21+ return False
22+
23+
924if TYPE_CHECKING :
1025 import pyarrow as pa
1126 from typing_extensions import Self
1631
1732else : # pragma: no cover
1833 import sys
19- from importlib .util import find_spec
2034
2135 if sys .version_info >= (3 , 13 ):
2236 from typing import TypeVar
23- elif find_spec ( "typing_extensions" ):
37+ elif _typing_extensions_has_pep_696 ( ):
2438 from typing_extensions import TypeVar
2539 else :
2640 from typing import TypeVar as _TypeVar
You can’t perform that action at this time.
0 commit comments