Skip to content

Commit

Permalink
Merge branch 'master' into resolve-some-docs-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gerzse authored Jul 18, 2024
2 parents 2a2ab33 + 7e2b4fb commit 11a0729
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
* Add `sum` to DUPLICATE_POLICY documentation of `TS.CREATE`, `TS.ADD` and `TS.ALTER`
* Prevent async ClusterPipeline instances from becoming "false-y" in case of empty command stack (#3061)
* Close Unix sockets if the connection attempt fails. This prevents `ResourceWarning`s. (#3314)
* Close SSL sockets if the connection attempt fails, or if validations fail. (#3317)

* 4.1.3 (Feb 8, 2022)
* Fix flushdb and flushall (#1926)
Expand Down
4 changes: 2 additions & 2 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
black==24.3.0
cachetools
click==8.0.4
flake8-isort==6.0.0
flake8==5.0.4
flake8-isort
flake8
flynt~=0.69.0
invoke==2.2.0
mock
Expand Down
2 changes: 1 addition & 1 deletion redis/_parsers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def parse_geosearch_generic(response, **options):
except KeyError: # it means the command was sent via execute_command
return response

if type(response) != list:
if not isinstance(response, list):
response_list = [response]
else:
response_list = response
Expand Down
3 changes: 0 additions & 3 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 +1381,6 @@ def failover(self):
)


AsyncManagementCommands = ManagementCommands


class AsyncManagementCommands(ManagementCommands):
async def command_info(self, **kwargs) -> None:
return super().command_info(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/timeseries/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, args):
self.chunk_size = response["chunkSize"]
if "duplicatePolicy" in response:
self.duplicate_policy = response["duplicatePolicy"]
if type(self.duplicate_policy) == bytes:
if isinstance(self.duplicate_policy, bytes):
self.duplicate_policy = self.duplicate_policy.decode()

def get(self, item):
Expand Down
5 changes: 3 additions & 2 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def _connect(self):
sock = super()._connect()
try:
return self._wrap_socket_with_ssl(sock)
except OSError:
except (OSError, RedisError):
sock.close()
raise

Expand Down Expand Up @@ -854,7 +854,6 @@ def _wrap_socket_with_ssl(self, sock):
context.minimum_version = self.ssl_min_version
if self.ssl_ciphers:
context.set_ciphers(self.ssl_ciphers)
sslsock = context.wrap_socket(sock, server_hostname=self.host)
if self.ssl_validate_ocsp is True and CRYPTOGRAPHY_AVAILABLE is False:
raise RedisError("cryptography is not installed.")

Expand All @@ -864,6 +863,8 @@ def _wrap_socket_with_ssl(self, sock):
"- not both."
)

sslsock = context.wrap_socket(sock, server_hostname=self.host)

# validation for the stapled case
if self.ssl_validate_ocsp_stapled:
import OpenSSL
Expand Down
6 changes: 2 additions & 4 deletions redis/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@
class CommandsProtocol(Protocol):
connection_pool: Union["AsyncConnectionPool", "ConnectionPool"]

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


class ClusterCommandsProtocol(CommandsProtocol, Protocol):
class ClusterCommandsProtocol(CommandsProtocol):
encoder: "Encoder"

def execute_command(self, *args, **options) -> Union[Any, Awaitable]: ...
1 change: 0 additions & 1 deletion tests/test_asyncio/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,6 @@ def test_connect_from_url_tcp(self):
connection = redis.Redis.from_url("redis://localhost")
pool = connection.connection_pool

print(repr(pool))
assert re.match(
r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >", repr(pool), re.VERBOSE
).groups() == (
Expand Down
2 changes: 1 addition & 1 deletion tests/test_asyncio/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@ def __init__(self, *args, **kwargs):
pass

lock = r.lock("foo", lock_class=MyLock)
assert type(lock) == MyLock
assert isinstance(lock, MyLock)
1 change: 0 additions & 1 deletion tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ def test_json_forget_with_dollar(client):
client.json().forget("not_a_document", "..a")


@pytest.mark.onlynoncluster
@pytest.mark.redismod
def test_json_mget_dollar(client):
# Test mget with multi paths
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,4 @@ def __init__(self, *args, **kwargs):
pass

lock = r.lock("foo", lock_class=MyLock)
assert type(lock) == MyLock
assert isinstance(lock, MyLock)

0 comments on commit 11a0729

Please sign in to comment.