python 3.10 compat re: TypeAlias

This commit is contained in:
sneakers-the-rat 2024-05-09 00:50:27 -07:00
parent b7d88c46c8
commit 0ee371ad05
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
3 changed files with 11 additions and 5 deletions

View file

@ -14,7 +14,13 @@ Check these using ``in`` rather than ``==``. This interface will develop in futu
versions to allow a single dtype check. 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 import numpy as np

View file

@ -18,10 +18,10 @@ except ImportError:
if sys.version_info.minor >= 10: if sys.version_info.minor >= 10:
from typing import TypeAlias from typing import TypeAlias
else:
from typing_extensions import TypeAlias
H5Arraylike: TypeAlias = Tuple[Union[Path, str], str] H5Arraylike: TypeAlias = Tuple[Union[Path, str], str]
else: # pragma: no cover
H5Arraylike = Tuple[Union[Path, str], str]
class H5ArrayPath(NamedTuple): class H5ArrayPath(NamedTuple):

View file

@ -4,7 +4,7 @@ import sys
import pytest import pytest
from typing import Any, Tuple, Union, Type from typing import Any, Tuple, Union, Type
if sys.version_info.minor >= 11: if sys.version_info.minor >= 10:
from typing import TypeAlias from typing import TypeAlias
else: else:
from typing_extensions import TypeAlias from typing_extensions import TypeAlias