typing.py 1.0 KB

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