diff --git a/pyproject.toml b/pyproject.toml index 97d84164..d1dc7120 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,6 +39,7 @@ twisted = ["Twisted", "fixtures"] dev = [ "ruff==0.14.11", "mypy>=1.0.0", + "typing-extensions;python_version<'3.11'", ] [tool.hatch.version] diff --git a/requirements.txt b/requirements.txt index e633ee5c..811aeed9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ fixtures>=2.0 -typing-extensions;python_version<'3.11' diff --git a/testtools/matchers/_higherorder.py b/testtools/matchers/_higherorder.py index 113b40d9..c0608c00 100644 --- a/testtools/matchers/_higherorder.py +++ b/testtools/matchers/_higherorder.py @@ -13,12 +13,13 @@ import sys import types from collections.abc import Callable, Iterable -from typing import Any, Generic, TypedDict, TypeVar +from typing import TYPE_CHECKING, Any, Generic, TypedDict, TypeVar -if sys.version_info >= (3, 11): - from typing import Unpack -else: - from typing_extensions import Unpack +if TYPE_CHECKING: + if sys.version_info >= (3, 11): + from typing import Unpack + else: + from typing_extensions import Unpack from ._impl import ( Matcher,