Skip to content

Commit 11a0729

Browse files
authored
Merge branch 'master' into resolve-some-docs-warnings
2 parents 2a2ab33 + 7e2b4fb commit 11a0729

File tree

11 files changed

+12
-17
lines changed

11 files changed

+12
-17
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
* Add `sum` to DUPLICATE_POLICY documentation of `TS.CREATE`, `TS.ADD` and `TS.ALTER`
6666
* Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3061)
6767
* Close Unix sockets if the connection attempt fails. This prevents `ResourceWarning`s. (#3314)
68+
* Close SSL sockets if the connection attempt fails, or if validations fail. (#3317)
6869

6970
* 4.1.3 (Feb 8, 2022)
7071
* Fix flushdb and flushall (#1926)

dev_requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
black==24.3.0
22
cachetools
33
click==8.0.4
4-
flake8-isort==6.0.0
5-
flake8==5.0.4
4+
flake8-isort
5+
flake8
66
flynt~=0.69.0
77
invoke==2.2.0
88
mock

redis/_parsers/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def parse_geosearch_generic(response, **options):
507507
except KeyError: # it means the command was sent via execute_command
508508
return response
509509

510-
if type(response) != list:
510+
if not isinstance(response, list):
511511
response_list = [response]
512512
else:
513513
response_list = response

redis/commands/core.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,9 +1381,6 @@ def failover(self):
13811381
)
13821382

13831383

1384-
AsyncManagementCommands = ManagementCommands
1385-
1386-
13871384
class AsyncManagementCommands(ManagementCommands):
13881385
async def command_info(self, **kwargs) -> None:
13891386
return super().command_info(**kwargs)

redis/commands/timeseries/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, args):
7878
self.chunk_size = response["chunkSize"]
7979
if "duplicatePolicy" in response:
8080
self.duplicate_policy = response["duplicatePolicy"]
81-
if type(self.duplicate_policy) == bytes:
81+
if isinstance(self.duplicate_policy, bytes):
8282
self.duplicate_policy = self.duplicate_policy.decode()
8383

8484
def get(self, item):

redis/connection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ def _connect(self):
819819
sock = super()._connect()
820820
try:
821821
return self._wrap_socket_with_ssl(sock)
822-
except OSError:
822+
except (OSError, RedisError):
823823
sock.close()
824824
raise
825825

@@ -854,7 +854,6 @@ def _wrap_socket_with_ssl(self, sock):
854854
context.minimum_version = self.ssl_min_version
855855
if self.ssl_ciphers:
856856
context.set_ciphers(self.ssl_ciphers)
857-
sslsock = context.wrap_socket(sock, server_hostname=self.host)
858857
if self.ssl_validate_ocsp is True and CRYPTOGRAPHY_AVAILABLE is False:
859858
raise RedisError("cryptography is not installed.")
860859

@@ -864,6 +863,8 @@ def _wrap_socket_with_ssl(self, sock):
864863
"- not both."
865864
)
866865

866+
sslsock = context.wrap_socket(sock, server_hostname=self.host)
867+
867868
# validation for the stapled case
868869
if self.ssl_validate_ocsp_stapled:
869870
import OpenSSL

redis/typing.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@
5454
class CommandsProtocol(Protocol):
5555
connection_pool: Union["AsyncConnectionPool", "ConnectionPool"]
5656

57-
def execute_command(self, *args, **options): ...
57+
def execute_command(self, *args, **options) -> ResponseT: ...
5858

5959

60-
class ClusterCommandsProtocol(CommandsProtocol, Protocol):
60+
class ClusterCommandsProtocol(CommandsProtocol):
6161
encoder: "Encoder"
62-
63-
def execute_command(self, *args, **options) -> Union[Any, Awaitable]: ...

tests/test_asyncio/test_connection_pool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ def test_connect_from_url_tcp(self):
647647
connection = redis.Redis.from_url("redis://localhost")
648648
pool = connection.connection_pool
649649

650-
print(repr(pool))
651650
assert re.match(
652651
r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >", repr(pool), re.VERBOSE
653652
).groups() == (

tests/test_asyncio/test_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,4 @@ def __init__(self, *args, **kwargs):
237237
pass
238238

239239
lock = r.lock("foo", lock_class=MyLock)
240-
assert type(lock) == MyLock
240+
assert isinstance(lock, MyLock)

tests/test_json.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ def test_json_forget_with_dollar(client):
446446
client.json().forget("not_a_document", "..a")
447447

448448

449-
@pytest.mark.onlynoncluster
450449
@pytest.mark.redismod
451450
def test_json_mget_dollar(client):
452451
# Test mget with multi paths

0 commit comments

Comments
 (0)