diff --git a/hypothesis-python/src/hypothesis/internal/compat.py b/hypothesis-python/src/hypothesis/internal/compat.py index c31640e025..e72b7a3eeb 100644 --- a/hypothesis-python/src/hypothesis/internal/compat.py +++ b/hypothesis-python/src/hypothesis/internal/compat.py @@ -16,7 +16,7 @@ import sys import typing from functools import partial -from typing import Any, ForwardRef, List, Optional, get_args +from typing import Any, ForwardRef, List, Optional, TypedDict as TypedDict, get_args try: BaseExceptionGroup = BaseExceptionGroup @@ -33,6 +33,7 @@ ParamSpec as ParamSpec, TypedDict as TypedDict, override as override, + TypeAlias as TypeAlias, ) else: # In order to use NotRequired, we need the version of TypedDict included in Python 3.11+. @@ -46,8 +47,6 @@ ) except ImportError: # We can use the old TypedDict from Python 3.8+ at runtime. - from typing import TypedDict as TypedDict - class NotRequired: """A runtime placeholder for the NotRequired type, which is not available in Python <3.11.""" @@ -59,6 +58,7 @@ def __class_getitem__(cls, item): Concatenate as Concatenate, ParamSpec as ParamSpec, override as override, + TypeAlias as TypeAlias ) except ImportError: try: @@ -66,9 +66,11 @@ def __class_getitem__(cls, item): Concatenate as Concatenate, ParamSpec as ParamSpec, override as override, + TypeAlias as TypeAlias, ) except ImportError: Concatenate, ParamSpec = None, None + TypeAlias = None override = lambda f: f diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/engine.py b/hypothesis-python/src/hypothesis/internal/conjecture/engine.py index d6c3150639..b726d43672 100644 --- a/hypothesis-python/src/hypothesis/internal/conjecture/engine.py +++ b/hypothesis-python/src/hypothesis/internal/conjecture/engine.py @@ -27,7 +27,6 @@ NoReturn, Optional, Set, - TypeAlias, Union, overload, ) @@ -45,6 +44,7 @@ ceil, int_from_bytes, override, + TypeAlias ) from hypothesis.internal.conjecture.data import ( AVAILABLE_PROVIDERS,