typing.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import sys
  2. import os
  3. from typing import Any, AsyncGenerator, Generator, AsyncIterator, Iterator, NewType, Tuple, Union, List, Dict, Type, IO, Optional
  4. try:
  5. from PIL.Image import Image
  6. except ImportError:
  7. class Image:
  8. pass
  9. if sys.version_info >= (3, 8):
  10. from typing import TypedDict
  11. else:
  12. from typing_extensions import TypedDict
  13. from .providers.response import ResponseType
  14. SHA256 = NewType('sha_256_hash', str)
  15. CreateResult = Iterator[Union[str, ResponseType]]
  16. AsyncResult = AsyncIterator[Union[str, ResponseType]]
  17. Messages = List[Dict[str, Union[str, List[Dict[str, Union[str, Dict[str, str]]]]]]]
  18. Cookies = Dict[str, str]
  19. ImageType = Union[str, bytes, IO, Image, os.PathLike]
  20. ImagesType = List[Tuple[ImageType, Optional[str]]]
  21. __all__ = [
  22. 'Any',
  23. 'AsyncGenerator',
  24. 'Generator',
  25. 'AsyncIterator',
  26. 'Iterator'
  27. 'Tuple',
  28. 'Union',
  29. 'List',
  30. 'Dict',
  31. 'Type',
  32. 'IO',
  33. 'Optional',
  34. 'TypedDict',
  35. 'SHA256',
  36. 'CreateResult',
  37. 'AsyncResult',
  38. 'Messages',
  39. 'Cookies',
  40. 'Image',
  41. 'ImageType',
  42. 'ImagesType'
  43. ]