Skip to content

Commit 60f7126

Browse files
authored
Merge pull request #571 from testing-cabal/avoid-extensions
Avoid importing typing extensions unless type checking
2 parents 53ec652 + 14ecca3 commit 60f7126

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ twisted = ["Twisted", "fixtures"]
3939
dev = [
4040
"ruff==0.14.11",
4141
"mypy>=1.0.0",
42+
"typing-extensions;python_version<'3.11'",
4243
]
4344

4445
[tool.hatch.version]

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
fixtures>=2.0
2-
typing-extensions;python_version<'3.11'

testtools/matchers/_higherorder.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
import sys
1414
import types
1515
from collections.abc import Callable, Iterable
16-
from typing import Any, Generic, TypedDict, TypeVar
16+
from typing import TYPE_CHECKING, Any, Generic, TypedDict, TypeVar
1717

18-
if sys.version_info >= (3, 11):
19-
from typing import Unpack
20-
else:
21-
from typing_extensions import Unpack
18+
if TYPE_CHECKING:
19+
if sys.version_info >= (3, 11):
20+
from typing import Unpack
21+
else:
22+
from typing_extensions import Unpack
2223

2324
from ._impl import (
2425
Matcher,

0 commit comments

Comments
 (0)