Skip to content

Commit 85a1302

Browse files
committed
made typing_extension optional
1 parent 82c96b2 commit 85a1302

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

curl_cffi/requests/session.py

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

3+
import sys
34
import asyncio
45
import queue
56
import threading
@@ -19,8 +20,8 @@
1920
TypedDict,
2021
Union,
2122
cast,
23+
Generic,
2224
)
23-
from typing_extensions import TypeVar, Generic
2425
from urllib.parse import urlparse
2526

2627
from ..aio import AsyncCurl
@@ -41,7 +42,15 @@
4142
with suppress(ImportError):
4243
import eventlet.tpool
4344

44-
R = TypeVar('R', bound=Response, default=Response)
45+
try:
46+
from typing_extensions import TypeVar
47+
except ImportError:
48+
from typing import TypeVar
49+
50+
if sys.version >= (3, 12):
51+
R = TypeVar('R', bound=Response, default=Response)
52+
else:
53+
R = TypeVar('R', bound=Response)
4554

4655
if TYPE_CHECKING:
4756
from typing_extensions import Unpack

0 commit comments

Comments
 (0)