Skip to content

Commit 0764489

Browse files
authored
Use typing-extensions only on Python < 3.8 (#44)
1 parent 55c0037 commit 0764489

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

asyncstdlib/_lrucache.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@
1717
)
1818
from functools import update_wrapper
1919
from collections import OrderedDict
20+
import sys
2021

21-
from typing_extensions import Protocol, TypedDict
22+
if sys.version_info[:2] >= (3, 8):
23+
from typing import Protocol, TypedDict
24+
else:
25+
from typing_extensions import Protocol, TypedDict
2226

2327
from ._utility import public_module
2428

asyncstdlib/asynctools.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
Any,
1111
overload,
1212
)
13-
from typing_extensions import AsyncContextManager
13+
import sys
14+
15+
if sys.version_info[:2] >= (3, 8):
16+
from typing import AsyncContextManager
17+
else:
18+
from typing_extensions import AsyncContextManager
1419

1520
from ._core import AnyIterable, aiter
1621
from .contextlib import nullcontext

asyncstdlib/contextlib.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88
Any,
99
Awaitable,
1010
)
11-
from typing_extensions import Protocol, AsyncContextManager, ContextManager
1211
from functools import wraps
1312
from collections import deque
1413
from functools import partial
1514
import sys
1615

16+
if sys.version_info[:2] >= (3, 8):
17+
from typing import Protocol, AsyncContextManager, ContextManager
18+
else:
19+
from typing_extensions import Protocol, AsyncContextManager, ContextManager
20+
1721
from ._core import awaitify
1822
from ._utility import public_module, slot_get as _slot_get
1923

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ classifiers = [
1616
"License :: OSI Approved :: MIT License",
1717
"Programming Language :: Python :: 3 :: Only",
1818
]
19-
requires = ["typing_extensions"]
19+
requires = ["typing_extensions; python_version<'3.8'"]
2020

2121
[tool.flit.metadata.requires-extra]
2222
test = [

0 commit comments

Comments
 (0)