|
5 | 5 | import logging |
6 | 6 | from contextlib import contextmanager |
7 | 7 | from datetime import timedelta |
8 | | -from typing import Any, Literal, Protocol |
| 8 | +from typing import Any, Literal, Protocol, cast |
9 | 9 |
|
10 | 10 | import redis |
11 | 11 | from typing_extensions import TypeAlias, deprecated |
@@ -76,7 +76,7 @@ def set( # noqa |
76 | 76 | ) -> bool | None: |
77 | 77 | raise NotImplementedError |
78 | 78 |
|
79 | | - def delete(self, keys: bytes | str | memoryview) -> Any: |
| 79 | + def delete(self, *names: bytes | str | memoryview) -> Any: |
80 | 80 | raise NotImplementedError |
81 | 81 |
|
82 | 82 |
|
@@ -185,22 +185,25 @@ def _init_client(self) -> RedisClientProtocol: |
185 | 185 | try: |
186 | 186 | if self.url: |
187 | 187 | logger.debug(f"Using URL format to connect to Cache: {self.host}") |
188 | | - return client.from_url(url=self.url) |
| 188 | + return cast(RedisClientProtocol, client.from_url(url=self.url)) |
189 | 189 | else: |
190 | 190 | # Cache in cluster mode doesn't support db parameter |
191 | 191 | extra_param_connection: dict[str, Any] = {} |
192 | 192 | if self.mode != "cluster": |
193 | 193 | extra_param_connection = {"db": self.db_index} |
194 | 194 |
|
195 | 195 | logger.debug(f"Using arguments to connect to Cache: {self.host}") |
196 | | - return client( |
197 | | - host=self.host, |
198 | | - port=self.port, |
199 | | - username=self.username, |
200 | | - password=self.password, |
201 | | - decode_responses=True, |
202 | | - ssl=self.ssl, |
203 | | - **extra_param_connection, |
| 196 | + return cast( |
| 197 | + RedisClientProtocol, |
| 198 | + client( |
| 199 | + host=self.host, |
| 200 | + port=self.port, |
| 201 | + username=self.username, |
| 202 | + password=self.password, |
| 203 | + decode_responses=True, |
| 204 | + ssl=self.ssl, |
| 205 | + **extra_param_connection, |
| 206 | + ), |
204 | 207 | ) |
205 | 208 | except redis.exceptions.ConnectionError as exc: |
206 | 209 | logger.debug(f"Cannot connect to Cache endpoint: {self.host}") |
|
0 commit comments