From ee1acee6dfe8784ff16f7dcdc35d00e292b02180 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 29 May 2019 16:37:28 +0200 Subject: [PATCH 1/4] StrictRedis is an alias for Redis in current redis --- third_party/2and3/redis/client.pyi | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/third_party/2and3/redis/client.pyi b/third_party/2and3/redis/client.pyi index f41676177336..95e35bee002a 100644 --- a/third_party/2and3/redis/client.pyi +++ b/third_party/2and3/redis/client.pyi @@ -31,7 +31,7 @@ def parse_hscan(response, **options): ... def parse_zscan(response, **options): ... def parse_slowlog_get(response, **options): ... -class StrictRedis: +class Redis(object): RESPONSE_CALLBACKS: Any @classmethod def from_url(cls, url, db=..., **kwargs): ... @@ -169,7 +169,7 @@ class StrictRedis: def srem(self, name, *values): ... def sunion(self, keys, *args): ... def sunionstore(self, dest, keys, *args): ... - def zadd(self, name, *args, **kwargs): ... + def zadd(self, name, mapping, nx: bool = ..., xx: bool = ..., ch: bool = ..., incr: bool = ...): ... def zcard(self, name): ... def zcount(self, name, min, max): ... def zincrby(self, name, value, amount=...): ... @@ -213,12 +213,7 @@ class StrictRedis: def script_load(self, script): ... def register_script(self, script): ... -class Redis(StrictRedis): - RESPONSE_CALLBACKS: Any - def pipeline(self, transaction=..., shard_hint=...): ... - def setex(self, name, value, time): ... - def lrem(self, name, value, num=...): ... - def zadd(self, name, *args, **kwargs): ... +StrictRedis = Redis class PubSub: PUBLISH_MESSAGE_TYPES: Any From 3483374975acde03a4a2091c407e97ad514ed269 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 29 May 2019 16:50:42 +0200 Subject: [PATCH 2/4] Add a few types --- third_party/2and3/redis/client.pyi | 47 +++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/third_party/2and3/redis/client.pyi b/third_party/2and3/redis/client.pyi index 95e35bee002a..64b8f9500b45 100644 --- a/third_party/2and3/redis/client.pyi +++ b/third_party/2and3/redis/client.pyi @@ -1,4 +1,7 @@ -from typing import Any +from datetime import timedelta +from typing import Any, Text, Optional, Mapping + +from .connection import ConnectionPool SYM_EMPTY: Any @@ -37,10 +40,30 @@ class Redis(object): def from_url(cls, url, db=..., **kwargs): ... connection_pool: Any response_callbacks: Any - def __init__(self, host=..., port=..., db=..., password=..., socket_timeout=..., socket_connect_timeout=..., - socket_keepalive=..., socket_keepalive_options=..., connection_pool=..., unix_socket_path=..., encoding=..., - encoding_errors=..., charset=..., errors=..., decode_responses=..., retry_on_timeout=..., ssl=..., - ssl_keyfile=..., ssl_certfile=..., ssl_cert_reqs=..., ssl_ca_certs=...) -> None: ... + def __init__( + self, + host: Text = ..., + port: int = ..., + db: int = ..., + password: Optional[Text] = ..., + socket_timeout: Optional[float] = ..., + socket_connect_timeout: Optional[float] = ..., + socket_keepalive: Optional[bool] = ..., + socket_keepalive_options: Optional[Mapping[str, Union[int, str]]] = ..., + connection_pool: Optional[ConnectionPool] = ..., + unix_socket_path: Optional[Text] = ..., + encoding: Text = ..., + encoding_errors: Text = ..., + charset: Optional[Text] = ..., + errors: Optional[Text] = ..., + decode_responses: bool = ..., + retry_on_timeout: bool = ..., + ssl: bool = ..., + ssl_keyfile: Optional[Text] = ..., + ssl_certfile: Optional[Text] = ..., + ssl_cert_reqs: Optional[Union[str, int]] = ..., + ssl_ca_certs: Optional[Text] = ..., + ) -> None: ... def set_response_callback(self, command, callback): ... def pipeline(self, transaction=..., shard_hint=...): ... def transaction(self, func, *watches, **kwargs): ... @@ -93,9 +116,9 @@ class Redis(object): def dump(self, name): ... def exists(self, name): ... __contains__: Any - def expire(self, name, time): ... + def expire(self, name: Text, time: Union[int, timedelta]) -> bool: ... def expireat(self, name, when): ... - def get(self, name): ... + def get(self, name: Text) -> Optional[bytes]: ... def __getitem__(self, name): ... def getbit(self, name, offset): ... def getrange(self, key, start, end): ... @@ -117,7 +140,15 @@ class Redis(object): def rename(self, src, dst): ... def renamenx(self, src, dst): ... def restore(self, name, ttl, value): ... - def set(self, name, value, ex=..., px=..., nx=..., xx=...): ... + def set( + self, + name: Text, + value: Any, + ex: Optional[int] = ..., + px: Optional[int] = ..., + nx: bool = ..., + xx: bool = ..., + ) -> Optional[bool]: ... def __setitem__(self, name, value): ... def setbit(self, name, offset, value): ... def setex(self, name, time, value): ... From 1c83db47c5fd1a8a9368bedb248ef16e4fabf147 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 29 May 2019 17:06:06 +0200 Subject: [PATCH 3/4] Add missing import --- third_party/2and3/redis/client.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/2and3/redis/client.pyi b/third_party/2and3/redis/client.pyi index 64b8f9500b45..120ca4c3c6a1 100644 --- a/third_party/2and3/redis/client.pyi +++ b/third_party/2and3/redis/client.pyi @@ -1,5 +1,5 @@ from datetime import timedelta -from typing import Any, Text, Optional, Mapping +from typing import Any, Text, Optional, Mapping, Union from .connection import ConnectionPool From a399f47e15268f643be3ced86d6191d923c80e01 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 12 Jun 2019 17:40:42 +0200 Subject: [PATCH 4/4] Add missing argument and types --- third_party/2and3/redis/client.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/third_party/2and3/redis/client.pyi b/third_party/2and3/redis/client.pyi index 120ca4c3c6a1..cd655964463a 100644 --- a/third_party/2and3/redis/client.pyi +++ b/third_party/2and3/redis/client.pyi @@ -63,6 +63,7 @@ class Redis(object): ssl_certfile: Optional[Text] = ..., ssl_cert_reqs: Optional[Union[str, int]] = ..., ssl_ca_certs: Optional[Text] = ..., + max_connections: Optional[int] = ..., ) -> None: ... def set_response_callback(self, command, callback): ... def pipeline(self, transaction=..., shard_hint=...): ... @@ -144,8 +145,8 @@ class Redis(object): self, name: Text, value: Any, - ex: Optional[int] = ..., - px: Optional[int] = ..., + ex: Union[None, int, timedelta] = ..., + px: Union[None, int, timedelta] = ..., nx: bool = ..., xx: bool = ..., ) -> Optional[bool]: ...