redis 5.3.0b3__py3-none-any.whl → 5.3.0b5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
redis/asyncio/client.py CHANGED
@@ -1554,7 +1554,7 @@ class Pipeline(Redis): # lgtm [py/init-calls-subclass]
1554
1554
  await self.reset()
1555
1555
  raise
1556
1556
 
1557
- async def execute(self, raise_on_error: bool = True):
1557
+ async def execute(self, raise_on_error: bool = True) -> List[Any]:
1558
1558
  """Execute all the commands in the current pipeline"""
1559
1559
  stack = self.command_stack
1560
1560
  if not stack and not self.watching:
redis/client.py CHANGED
@@ -4,7 +4,17 @@ import threading
4
4
  import time
5
5
  import warnings
6
6
  from itertools import chain
7
- from typing import Any, Callable, Dict, List, Optional, Type, Union
7
+ from typing import (
8
+ TYPE_CHECKING,
9
+ Any,
10
+ Callable,
11
+ Dict,
12
+ List,
13
+ Mapping,
14
+ Optional,
15
+ Type,
16
+ Union,
17
+ )
8
18
 
9
19
  from redis._parsers.encoders import Encoder
10
20
  from redis._parsers.helpers import (
@@ -53,6 +63,11 @@ from redis.utils import (
53
63
  str_if_bytes,
54
64
  )
55
65
 
66
+ if TYPE_CHECKING:
67
+ import ssl
68
+
69
+ import OpenSSL
70
+
56
71
  SYM_EMPTY = b""
57
72
  EMPTY_RESPONSE = "EMPTY_RESPONSE"
58
73
 
@@ -175,47 +190,47 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
175
190
 
176
191
  def __init__(
177
192
  self,
178
- host="localhost",
179
- port=6379,
180
- db=0,
181
- password=None,
182
- socket_timeout=None,
183
- socket_connect_timeout=None,
184
- socket_keepalive=None,
185
- socket_keepalive_options=None,
186
- connection_pool=None,
187
- unix_socket_path=None,
188
- encoding="utf-8",
189
- encoding_errors="strict",
190
- charset=None,
191
- errors=None,
192
- decode_responses=False,
193
- retry_on_timeout=False,
194
- retry_on_error=None,
195
- ssl=False,
196
- ssl_keyfile=None,
197
- ssl_certfile=None,
198
- ssl_cert_reqs="required",
199
- ssl_ca_certs=None,
200
- ssl_ca_path=None,
201
- ssl_ca_data=None,
202
- ssl_check_hostname=False,
203
- ssl_password=None,
204
- ssl_validate_ocsp=False,
205
- ssl_validate_ocsp_stapled=False,
206
- ssl_ocsp_context=None,
207
- ssl_ocsp_expected_cert=None,
208
- ssl_min_version=None,
209
- ssl_ciphers=None,
210
- max_connections=None,
211
- single_connection_client=False,
212
- health_check_interval=0,
213
- client_name=None,
214
- lib_name="redis-py",
215
- lib_version=get_lib_version(),
216
- username=None,
217
- retry=None,
218
- redis_connect_func=None,
193
+ host: str = "localhost",
194
+ port: int = 6379,
195
+ db: int = 0,
196
+ password: Optional[str] = None,
197
+ socket_timeout: Optional[float] = None,
198
+ socket_connect_timeout: Optional[float] = None,
199
+ socket_keepalive: Optional[bool] = None,
200
+ socket_keepalive_options: Optional[Mapping[int, Union[int, bytes]]] = None,
201
+ connection_pool: Optional[ConnectionPool] = None,
202
+ unix_socket_path: Optional[str] = None,
203
+ encoding: str = "utf-8",
204
+ encoding_errors: str = "strict",
205
+ charset: Optional[str] = None,
206
+ errors: Optional[str] = None,
207
+ decode_responses: bool = False,
208
+ retry_on_timeout: bool = False,
209
+ retry_on_error: Optional[List[Type[Exception]]] = None,
210
+ ssl: bool = False,
211
+ ssl_keyfile: Optional[str] = None,
212
+ ssl_certfile: Optional[str] = None,
213
+ ssl_cert_reqs: str = "required",
214
+ ssl_ca_certs: Optional[str] = None,
215
+ ssl_ca_path: Optional[str] = None,
216
+ ssl_ca_data: Optional[str] = None,
217
+ ssl_check_hostname: bool = False,
218
+ ssl_password: Optional[str] = None,
219
+ ssl_validate_ocsp: bool = False,
220
+ ssl_validate_ocsp_stapled: bool = False,
221
+ ssl_ocsp_context: Optional["OpenSSL.SSL.Context"] = None,
222
+ ssl_ocsp_expected_cert: Optional[str] = None,
223
+ ssl_min_version: Optional["ssl.TLSVersion"] = None,
224
+ ssl_ciphers: Optional[str] = None,
225
+ max_connections: Optional[int] = None,
226
+ single_connection_client: bool = False,
227
+ health_check_interval: int = 0,
228
+ client_name: Optional[str] = None,
229
+ lib_name: Optional[str] = "redis-py",
230
+ lib_version: Optional[str] = get_lib_version(),
231
+ username: Optional[str] = None,
232
+ retry: Optional[Retry] = None,
233
+ redis_connect_func: Optional[Callable[[], None]] = None,
219
234
  credential_provider: Optional[CredentialProvider] = None,
220
235
  protocol: Optional[int] = 2,
221
236
  cache: Optional[CacheInterface] = None,
@@ -550,7 +565,7 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
550
565
  def __del__(self):
551
566
  self.close()
552
567
 
553
- def close(self):
568
+ def close(self) -> None:
554
569
  # In case a connection property does not yet exist
555
570
  # (due to a crash earlier in the Redis() constructor), return
556
571
  # immediately as there is nothing to clean-up.
@@ -1551,11 +1566,10 @@ class Pipeline(Redis):
1551
1566
  conn.retry_on_error is None
1552
1567
  or isinstance(error, tuple(conn.retry_on_error)) is False
1553
1568
  ):
1554
-
1555
1569
  self.reset()
1556
1570
  raise error
1557
1571
 
1558
- def execute(self, raise_on_error=True):
1572
+ def execute(self, raise_on_error: bool = True) -> List[Any]:
1559
1573
  """Execute all the commands in the current pipeline"""
1560
1574
  stack = self.command_stack
1561
1575
  if not stack and not self.watching:
redis/cluster.py CHANGED
@@ -1244,7 +1244,7 @@ class RedisCluster(AbstractRedisCluster, RedisClusterCommands):
1244
1244
 
1245
1245
  raise ClusterError("TTL exhausted.")
1246
1246
 
1247
- def close(self):
1247
+ def close(self) -> None:
1248
1248
  try:
1249
1249
  with self._lock:
1250
1250
  if self.nodes_manager:
@@ -1686,7 +1686,7 @@ class NodesManager:
1686
1686
  # If initialize was called after a MovedError, clear it
1687
1687
  self._moved_exception = None
1688
1688
 
1689
- def close(self):
1689
+ def close(self) -> None:
1690
1690
  self.default_node = None
1691
1691
  for node in self.nodes_cache.values():
1692
1692
  if node.redis_connection:
@@ -2067,7 +2067,7 @@ class ClusterPipeline(RedisCluster):
2067
2067
  )
2068
2068
  exception.args = (msg,) + exception.args[1:]
2069
2069
 
2070
- def execute(self, raise_on_error=True):
2070
+ def execute(self, raise_on_error: bool = True) -> List[Any]:
2071
2071
  """
2072
2072
  Execute all the commands in the current pipeline
2073
2073
  """
redis/connection.py CHANGED
@@ -9,7 +9,7 @@ from abc import abstractmethod
9
9
  from itertools import chain
10
10
  from queue import Empty, Full, LifoQueue
11
11
  from time import time
12
- from typing import Any, Callable, Dict, List, Optional, Type, Union
12
+ from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union
13
13
  from urllib.parse import parse_qs, unquote, urlparse
14
14
 
15
15
  from redis.cache import (
@@ -904,9 +904,11 @@ class CacheProxyConnection(ConnectionInterface):
904
904
  and self._cache.get(self._current_command_cache_key).status
905
905
  != CacheEntryStatus.IN_PROGRESS
906
906
  ):
907
- return copy.deepcopy(
907
+ res = copy.deepcopy(
908
908
  self._cache.get(self._current_command_cache_key).cache_value
909
909
  )
910
+ self._current_command_cache_key = None
911
+ return res
910
912
 
911
913
  response = self._conn.read_response(
912
914
  disable_decoding=disable_decoding,
@@ -932,6 +934,8 @@ class CacheProxyConnection(ConnectionInterface):
932
934
  cache_entry.cache_value = response
933
935
  self._cache.set(cache_entry)
934
936
 
937
+ self._current_command_cache_key = None
938
+
935
939
  return response
936
940
 
937
941
  def pack_command(self, *args):
@@ -1259,6 +1263,9 @@ def parse_url(url):
1259
1263
  return kwargs
1260
1264
 
1261
1265
 
1266
+ _CP = TypeVar("_CP", bound="ConnectionPool")
1267
+
1268
+
1262
1269
  class ConnectionPool:
1263
1270
  """
1264
1271
  Create a connection pool. ``If max_connections`` is set, then this
@@ -1274,7 +1281,7 @@ class ConnectionPool:
1274
1281
  """
1275
1282
 
1276
1283
  @classmethod
1277
- def from_url(cls, url, **kwargs):
1284
+ def from_url(cls: Type[_CP], url: str, **kwargs) -> _CP:
1278
1285
  """
1279
1286
  Return a connection pool configured from the given URL.
1280
1287
 
@@ -1374,6 +1381,7 @@ class ConnectionPool:
1374
1381
  # will notice the first thread already did the work and simply
1375
1382
  # release the lock.
1376
1383
  self._fork_lock = threading.Lock()
1384
+ self._lock = threading.Lock()
1377
1385
  self.reset()
1378
1386
 
1379
1387
  def __repr__(self) -> (str, str):
@@ -1391,7 +1399,6 @@ class ConnectionPool:
1391
1399
  return self.connection_kwargs.get("protocol", None)
1392
1400
 
1393
1401
  def reset(self) -> None:
1394
- self._lock = threading.Lock()
1395
1402
  self._created_connections = 0
1396
1403
  self._available_connections = []
1397
1404
  self._in_use_connections = set()
redis/typing.py CHANGED
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
20
20
 
21
21
 
22
22
  Number = Union[int, float]
23
- EncodedT = Union[bytes, memoryview]
23
+ EncodedT = Union[bytes, bytearray, memoryview]
24
24
  DecodedT = Union[str, int, float]
25
25
  EncodableT = Union[EncodedT, DecodedT]
26
26
  AbsExpiryT = Union[int, datetime]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: redis
3
- Version: 5.3.0b3
3
+ Version: 5.3.0b5
4
4
  Summary: Python client for Redis database and key-value store
5
5
  Home-page: https://github.com/redis/redis-py
6
6
  Author: Redis Inc.
@@ -30,6 +30,7 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
30
30
  Requires-Python: >=3.8
31
31
  Description-Content-Type: text/markdown
32
32
  License-File: LICENSE
33
+ Requires-Dist: PyJWT~=2.9.0
33
34
  Requires-Dist: async-timeout>=4.0.3; python_full_version < "3.11.3"
34
35
  Provides-Extra: hiredis
35
36
  Requires-Dist: hiredis>=3.0.0; extra == "hiredis"
@@ -1,9 +1,9 @@
1
1
  redis/__init__.py,sha256=WlARnwwst8oaEyjXV5XTcmSGyEKVCn3S9N1MrHyJ8U8,2015
2
2
  redis/backoff.py,sha256=N2CZXkB3cdoHeMZ01r0zVry0bRKe8mk0ybi8hE7PvzU,3177
3
3
  redis/cache.py,sha256=68rJDNogvNwgdgBel6zSX9QziL11qsKIMhmvQvHvznM,9549
4
- redis/client.py,sha256=MMDn5Qh6rcBx2sDFU4O_Jid5TdzhA3-91_sxzmOBWAM,61055
5
- redis/cluster.py,sha256=4UBn9HoGjKGUZ-ILROSVw-4I3Kg_9YW8r0X4COKwPsI,95882
6
- redis/connection.py,sha256=UXrGt2T_1ebCGnpTmIzafZRLiZyqMJi4LOsRFkaFVHU,64750
4
+ redis/client.py,sha256=Y1jpN3nx4OEhFDRlcPDzjMuL4prwdPftsLlaQ8oY3tY,61876
5
+ redis/cluster.py,sha256=tHaV56B7Yt-x3y-XNMy1jlARoTkk2lkoFY9yY_Nfl0w,95919
6
+ redis/connection.py,sha256=kSG_LyYrxgsLtcpfJRmeh7N6yZ_o_f0WaZqE5-Imf10,64962
7
7
  redis/crc.py,sha256=Z3kXFtkY2LdgefnQMud1xr4vG5UYvA9LCMqNMX1ywu4,729
8
8
  redis/credentials.py,sha256=GOnO3-LSW34efHaIrUbS742Mw8l70mRzF6UrKiKZsMY,1828
9
9
  redis/event.py,sha256=urOK241IdgmCQ3fq7GqXRstZ2vcXRV14bBBMdN3latk,12129
@@ -13,7 +13,7 @@ redis/ocsp.py,sha256=4b1s43x-DJ859zRKtwGTIbNys_dyGv5YyOdWnOvigyM,11451
13
13
  redis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  redis/retry.py,sha256=JiIDxeD890vgi_me8pwypO1LixwhU0Fv3A5NEay8SAY,2206
15
15
  redis/sentinel.py,sha256=ya1aPeAvUcY9qXMSpV_wA3081vUqkIqcyXG9SqAvU88,14661
16
- redis/typing.py,sha256=skQl2VuyL7fPpg2BRDlGYMmwDQ2BLwwxxR8u_V1Kbm4,2138
16
+ redis/typing.py,sha256=k7F_3Vtsexeb7mUl6txlwrY1veGDLEhtcHe9FwIJOOo,2149
17
17
  redis/utils.py,sha256=oTonIc6DbbB-ZT-mL14ChhcFk2y4qnK3UNORMKPj2oI,4787
18
18
  redis/_parsers/__init__.py,sha256=qkfgV2X9iyvQAvbLdSelwgz0dCk9SGAosCvuZC9-qDc,550
19
19
  redis/_parsers/base.py,sha256=0j3qIhLjQZOzYGc4n1IesNegckomVhvDsEZD6-yb3Ns,7475
@@ -25,7 +25,7 @@ redis/_parsers/resp2.py,sha256=f22kH-_ZP2iNtOn6xOe65MSy_fJpu8OEn1u_hgeeojI,4813
25
25
  redis/_parsers/resp3.py,sha256=jHtL1LYJegJ_LiNTsjzIvS-kZyNR58jZ_YV4cRfwuN0,11127
26
26
  redis/_parsers/socket.py,sha256=CKD8QW_wFSNlIZzxlbNduaGpiv0I8wBcsGuAIojDfJg,5403
27
27
  redis/asyncio/__init__.py,sha256=uoDD8XYVi0Kj6mcufYwLDUTQXmBRx7a0bhKF9stZr7I,1489
28
- redis/asyncio/client.py,sha256=xxifh7JrWJkSPpbem1qVXV6sCvAQRlq4VCYrkj84yvQ,61176
28
+ redis/asyncio/client.py,sha256=QNt2SXY_kH-8DyGfLylCWYVvu32RgW9LQGbYwVr0PFs,61189
29
29
  redis/asyncio/cluster.py,sha256=c3dhOQjMUdXQO0WJCOn6-DTPxk-mbcgw52OpiSDrfG8,65243
30
30
  redis/asyncio/connection.py,sha256=w4yYr2Pzx_8Q7uJbeEyqZrjrqBpXaEZFYHZC5Zuv5HA,47203
31
31
  redis/asyncio/lock.py,sha256=lLasXEO2E1CskhX5ZZoaSGpmwZP1Q782R3HAUNG3wD4,11967
@@ -75,8 +75,8 @@ redis/commands/timeseries/__init__.py,sha256=gkz6wshEzzQQryBOnrAqqQzttS-AHfXmuN_
75
75
  redis/commands/timeseries/commands.py,sha256=8Z2BEyP23qTYCJR_e9zdG11yWmIDwGBMO2PJNLtK2BA,47147
76
76
  redis/commands/timeseries/info.py,sha256=meZYdu7IV9KaUWMKZs9qW4vo3Q9MwhdY-EBtKQzls5o,3223
77
77
  redis/commands/timeseries/utils.py,sha256=NLwSOS5Dz9N8dYQSzEyBIvrItOWwfQ0xgDj8un6x3dU,1319
78
- redis-5.3.0b3.dist-info/LICENSE,sha256=pXslClvwPXr-VbdAYzE_Ktt7ANVGwKsUmok5gzP-PMg,1074
79
- redis-5.3.0b3.dist-info/METADATA,sha256=-wR2WJlqo5dVm6xSA2HiBdbI5Sawtc5hwKdce1OhOms,9140
80
- redis-5.3.0b3.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
81
- redis-5.3.0b3.dist-info/top_level.txt,sha256=OMAefszlde6ZoOtlM35AWzpRIrwtcqAMHGlRit-w2-4,6
82
- redis-5.3.0b3.dist-info/RECORD,,
78
+ redis-5.3.0b5.dist-info/LICENSE,sha256=pXslClvwPXr-VbdAYzE_Ktt7ANVGwKsUmok5gzP-PMg,1074
79
+ redis-5.3.0b5.dist-info/METADATA,sha256=Yyhzrqr54WowER_VsnpCiOUGI6WHgE5ECvqrgFJB57U,9168
80
+ redis-5.3.0b5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
81
+ redis-5.3.0b5.dist-info/top_level.txt,sha256=OMAefszlde6ZoOtlM35AWzpRIrwtcqAMHGlRit-w2-4,6
82
+ redis-5.3.0b5.dist-info/RECORD,,