1from __future__ import annotations
2
3import os
4import sys
5from typing import Any, Protocol, Sequence, TypeVar, Union
6
7try:
8 import numpy.typing as npt
9
10 NumpyArray = npt.NDArray[Any]
11except ImportError:
12 pass
13
14if sys.version_info >= (3, 10):
15 from typing import TypeGuard
16else:
17 try:
18 from typing_extensions import TypeGuard
19 except ImportError:
20
21 class TypeGuard: # type: ignore[no-redef]
22 def __class_getitem__(cls, item: Any) -> type[bool]:
23 return bool
24
25
26Coords = Union[Sequence[float], Sequence[Sequence[float]]]
27
28
29_T_co = TypeVar("_T_co", covariant=True)
30
31
32class SupportsRead(Protocol[_T_co]):
33 def read(self, __length: int = ...) -> _T_co: ...
34
35
36StrOrBytesPath = Union[str, bytes, "os.PathLike[str]", "os.PathLike[bytes]"]
37
38
39__all__ = ["TypeGuard", "StrOrBytesPath", "SupportsRead"]