txredisapi.pyi 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2020 The Matrix.org Foundation C.I.C.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """Contains *incomplete* type hints for txredisapi.
  16. """
  17. from typing import Any, List, Optional, Type, Union
  18. class RedisProtocol:
  19. def publish(self, channel: str, message: bytes): ...
  20. async def ping(self) -> None: ...
  21. async def set(
  22. self,
  23. key: str,
  24. value: Any,
  25. expire: Optional[int] = None,
  26. pexpire: Optional[int] = None,
  27. only_if_not_exists: bool = False,
  28. only_if_exists: bool = False,
  29. ) -> None: ...
  30. async def get(self, key: str) -> Any: ...
  31. class SubscriberProtocol(RedisProtocol):
  32. def __init__(self, *args, **kwargs): ...
  33. password: Optional[str]
  34. def subscribe(self, channels: Union[str, List[str]]): ...
  35. def connectionMade(self): ...
  36. def connectionLost(self, reason): ...
  37. def lazyConnection(
  38. host: str = ...,
  39. port: int = ...,
  40. dbid: Optional[int] = ...,
  41. reconnect: bool = ...,
  42. charset: str = ...,
  43. password: Optional[str] = ...,
  44. connectTimeout: Optional[int] = ...,
  45. replyTimeout: Optional[int] = ...,
  46. convertNumbers: bool = ...,
  47. ) -> RedisProtocol: ...
  48. class ConnectionHandler: ...
  49. class RedisFactory:
  50. continueTrying: bool
  51. handler: RedisProtocol
  52. pool: List[RedisProtocol]
  53. replyTimeout: Optional[int]
  54. def __init__(
  55. self,
  56. uuid: str,
  57. dbid: Optional[int],
  58. poolsize: int,
  59. isLazy: bool = False,
  60. handler: Type = ConnectionHandler,
  61. charset: str = "utf-8",
  62. password: Optional[str] = None,
  63. replyTimeout: Optional[int] = None,
  64. convertNumbers: Optional[int] = True,
  65. ): ...
  66. def buildProtocol(self, addr) -> RedisProtocol: ...
  67. class SubscriberFactory(RedisFactory):
  68. def __init__(self): ...