From 0ee371ad055f18448062f402ceb7f1934163c919 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Thu, 9 May 2024 00:50:27 -0700 Subject: [PATCH] python 3.10 compat re: TypeAlias --- src/numpydantic/dtype.py | 8 +++++++- src/numpydantic/interface/hdf5.py | 6 +++--- tests/conftest.py | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/numpydantic/dtype.py b/src/numpydantic/dtype.py index d25bcd1..5a292c5 100644 --- a/src/numpydantic/dtype.py +++ b/src/numpydantic/dtype.py @@ -14,7 +14,13 @@ Check these using ``in`` rather than ``==``. This interface will develop in futu versions to allow a single dtype check. """ -from typing import Tuple, TypeAlias, Union +import sys +from typing import Tuple, Union + +if sys.version_info.minor >= 10: + from typing import TypeAlias +else: + from typing_extensions import TypeAlias import numpy as np diff --git a/src/numpydantic/interface/hdf5.py b/src/numpydantic/interface/hdf5.py index fcde4d4..67cecda 100644 --- a/src/numpydantic/interface/hdf5.py +++ b/src/numpydantic/interface/hdf5.py @@ -18,10 +18,10 @@ except ImportError: if sys.version_info.minor >= 10: from typing import TypeAlias +else: + from typing_extensions import TypeAlias - H5Arraylike: TypeAlias = Tuple[Union[Path, str], str] -else: # pragma: no cover - H5Arraylike = Tuple[Union[Path, str], str] +H5Arraylike: TypeAlias = Tuple[Union[Path, str], str] class H5ArrayPath(NamedTuple): diff --git a/tests/conftest.py b/tests/conftest.py index 46a9a49..c716dec 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,7 +4,7 @@ import sys import pytest from typing import Any, Tuple, Union, Type -if sys.version_info.minor >= 11: +if sys.version_info.minor >= 10: from typing import TypeAlias else: from typing_extensions import TypeAlias