_typing.py 919 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. from __future__ import annotations
  2. import os
  3. import sys
  4. from collections.abc import Sequence
  5. from typing import Any, Protocol, TypeVar
  6. TYPE_CHECKING = False
  7. if TYPE_CHECKING:
  8. from numbers import _IntegralLike as IntegralLike
  9. try:
  10. import numpy.typing as npt
  11. NumpyArray = npt.NDArray[Any]
  12. except ImportError:
  13. pass
  14. if sys.version_info >= (3, 13):
  15. from types import CapsuleType
  16. else:
  17. CapsuleType = object
  18. if sys.version_info >= (3, 12):
  19. from collections.abc import Buffer
  20. else:
  21. Buffer = Any
  22. _Ink = float | tuple[int, ...] | str
  23. Coords = Sequence[float] | Sequence[Sequence[float]]
  24. _T_co = TypeVar("_T_co", covariant=True)
  25. class SupportsRead(Protocol[_T_co]):
  26. def read(self, length: int = ..., /) -> _T_co: ...
  27. StrOrBytesPath = str | bytes | os.PathLike[str] | os.PathLike[bytes]
  28. __all__ = ["Buffer", "IntegralLike", "StrOrBytesPath", "SupportsRead"]