Skip to content

Commit 45dd0b7

Browse files
authored
Merge branch 'master' into enterprise-tests
2 parents cf78401 + 07fc339 commit 45dd0b7

38 files changed

+513
-295
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ exclude =
1616
ignore =
1717
E126
1818
E203
19+
E701
20+
E704
1921
F405
2022
N801
2123
N802

.github/workflows/docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
- cron: '0 1 * * *' # nightly build
1414

1515
concurrency:
16-
group: ${{ github.event.pull_request.number || github.ref }}
16+
group: ${{ github.event.pull_request.number || github.ref }}-docs
1717
cancel-in-progress: true
1818

1919
permissions:

.github/workflows/integration.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ on:
1717
- cron: '0 1 * * *' # nightly build
1818

1919
concurrency:
20-
group: ${{ github.event.pull_request.number || github.ref }}
20+
group: ${{ github.event.pull_request.number || github.ref }}-integration
2121
cancel-in-progress: true
2222

2323
permissions:
@@ -88,7 +88,7 @@ jobs:
8888
path: '${{matrix.test-type}}*results.xml'
8989

9090
- name: Upload codecov coverage
91-
uses: codecov/codecov-action@v3
91+
uses: codecov/codecov-action@v4
9292
with:
9393
fail_ci_if_error: false
9494

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
# Drafts your next Release notes as Pull Requests are merged into "master"
19-
- uses: release-drafter/release-drafter@v5
19+
- uses: release-drafter/release-drafter@v6
2020
with:
2121
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
2222
config-name: release-drafter-config.yml

.github/workflows/spellcheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
- name: Checkout
99
uses: actions/checkout@v4
1010
- name: Check Spelling
11-
uses: rojopolis/spellcheck-github-actions@0.35.0
11+
uses: rojopolis/spellcheck-github-actions@0.36.0
1212
with:
1313
config_path: .github/spellcheck-settings.yml
1414
task_name: Markdown

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Allow to control the minimum SSL version
12
* Add an optional lock_name attribute to LockError.
23
* Fix return types for `get`, `set_path` and `strappend` in JSONCommands
34
* Connection.register_connect_callback() is made public.

dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
click==8.0.4
2-
black==22.3.0
2+
black==24.3.0
33
flake8==5.0.4
44
flake8-isort==6.0.0
55
flynt~=0.69.0

docs/examples/asyncio_examples.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"\n",
1616
"## Connecting and Disconnecting\n",
1717
"\n",
18-
"Utilizing asyncio Redis requires an explicit disconnect of the connection since there is no asyncio deconstructor magic method. By default, a connection pool is created on `redis.Redis()` and attached to this `Redis` instance. The connection pool closes automatically on the call to `Redis.aclose` which disconnects all connections."
18+
"Using asyncio Redis requires an explicit disconnect of the connection since there is no asyncio deconstructor magic method. By default, an internal connection pool is created on `redis.Redis()` and attached to the `Redis` instance. When calling `Redis.aclose` this internal connection pool closes automatically, which disconnects all connections."
1919
]
2020
},
2121
{
@@ -48,7 +48,7 @@
4848
"cell_type": "markdown",
4949
"metadata": {},
5050
"source": [
51-
"If you create custom `ConnectionPool` for the `Redis` instance to use alone, use the `from_pool` class method to create it. This will cause the pool to be disconnected along with the Redis instance. Disconnecting the connection pool simply disconnects all connections hosted in the pool."
51+
"If you create a custom `ConnectionPool` to be used by a single `Redis` instance, use the `Redis.from_pool` class method. The Redis client will take ownership of the connection pool. This will cause the pool to be disconnected along with the Redis instance. Disconnecting the connection pool simply disconnects all connections hosted in the pool."
5252
]
5353
},
5454
{
@@ -61,7 +61,7 @@
6161
"\n",
6262
"pool = redis.ConnectionPool.from_url(\"redis://localhost\")\n",
6363
"client = redis.Redis.from_pool(pool)\n",
64-
"await client.close()"
64+
"await client.aclose()"
6565
]
6666
},
6767
{
@@ -74,7 +74,7 @@
7474
},
7575
"source": [
7676
"\n",
77-
"However, If you supply a `ConnectionPool` that is shared several `Redis` instances, you may want to disconnect the connection pool explicitly. use the `connection_pool` argument in that case."
77+
"However, if the `ConnectionPool` is to be shared by several `Redis` instances, you should use the `connection_pool` argument, and you may want to disconnect the connection pool explicitly."
7878
]
7979
},
8080
{
@@ -201,7 +201,7 @@
201201
"\n",
202202
"async def reader(channel: redis.client.PubSub):\n",
203203
" while True:\n",
204-
" message = await channel.get_message(ignore_subscribe_messages=True)\n",
204+
" message = await channel.get_message(ignore_subscribe_messages=True, timeout=None)\n",
205205
" if message is not None:\n",
206206
" print(f\"(Reader) Message Received: {message}\")\n",
207207
" if message[\"data\"].decode() == STOPWORD:\n",
@@ -264,7 +264,7 @@
264264
"\n",
265265
"async def reader(channel: redis.client.PubSub):\n",
266266
" while True:\n",
267-
" message = await channel.get_message(ignore_subscribe_messages=True)\n",
267+
" message = await channel.get_message(ignore_subscribe_messages=True, timeout=None)\n",
268268
" if message is not None:\n",
269269
" print(f\"(Reader) Message Received: {message}\")\n",
270270
" if message[\"data\"].decode() == STOPWORD:\n",

docs/examples/ssl_connection_examples.ipynb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,42 @@
7676
"ssl_connection.ping()"
7777
]
7878
},
79+
{
80+
"cell_type": "markdown",
81+
"metadata": {},
82+
"source": [
83+
"## Connecting to a Redis instance via SSL, while specifying a minimum TLS version"
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": null,
89+
"metadata": {},
90+
"outputs": [
91+
{
92+
"data": {
93+
"text/plain": [
94+
"True"
95+
]
96+
},
97+
"execution_count": 6,
98+
"metadata": {},
99+
"output_type": "execute_result"
100+
}
101+
],
102+
"source": [
103+
"import redis\n",
104+
"import ssl\n",
105+
"\n",
106+
"ssl_conn = redis.Redis(\n",
107+
" host=\"localhost\",\n",
108+
" port=6666,\n",
109+
" ssl=True,\n",
110+
" ssl_min_version=ssl.TLSVersion.TLSv1_3,\n",
111+
")\n",
112+
"ssl_conn.ping()"
113+
]
114+
},
79115
{
80116
"cell_type": "markdown",
81117
"metadata": {},

redis/_parsers/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async def can_read_destructive(self) -> bool:
182182
return True
183183
try:
184184
async with async_timeout(0):
185-
return await self._stream.read(1)
185+
return self._stream.at_eof()
186186
except TimeoutError:
187187
return False
188188

redis/_parsers/helpers.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -831,30 +831,31 @@ def string_keys_to_dict(key_string, callback):
831831
lambda r, **kwargs: r,
832832
),
833833
**string_keys_to_dict("XREAD XREADGROUP", parse_xread_resp3),
834-
"ACL LOG": lambda r: [
835-
{str_if_bytes(key): str_if_bytes(value) for key, value in x.items()} for x in r
836-
]
837-
if isinstance(r, list)
838-
else bool_ok(r),
834+
"ACL LOG": lambda r: (
835+
[
836+
{str_if_bytes(key): str_if_bytes(value) for key, value in x.items()}
837+
for x in r
838+
]
839+
if isinstance(r, list)
840+
else bool_ok(r)
841+
),
839842
"COMMAND": parse_command_resp3,
840843
"CONFIG GET": lambda r: {
841-
str_if_bytes(key)
842-
if key is not None
843-
else None: str_if_bytes(value)
844-
if value is not None
845-
else None
844+
str_if_bytes(key) if key is not None else None: (
845+
str_if_bytes(value) if value is not None else None
846+
)
846847
for key, value in r.items()
847848
},
848849
"MEMORY STATS": lambda r: {str_if_bytes(key): value for key, value in r.items()},
849850
"SENTINEL MASTER": parse_sentinel_state_resp3,
850851
"SENTINEL MASTERS": parse_sentinel_masters_resp3,
851852
"SENTINEL SENTINELS": parse_sentinel_slaves_and_sentinels_resp3,
852853
"SENTINEL SLAVES": parse_sentinel_slaves_and_sentinels_resp3,
853-
"STRALGO": lambda r, **options: {
854-
str_if_bytes(key): str_if_bytes(value) for key, value in r.items()
855-
}
856-
if isinstance(r, dict)
857-
else str_if_bytes(r),
854+
"STRALGO": lambda r, **options: (
855+
{str_if_bytes(key): str_if_bytes(value) for key, value in r.items()}
856+
if isinstance(r, dict)
857+
else str_if_bytes(r)
858+
),
858859
"XINFO CONSUMERS": lambda r: [
859860
{str_if_bytes(key): value for key, value in x.items()} for x in r
860861
],

redis/_parsers/resp3.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ def _read_response(self, disable_decoding=False, push_request=False):
117117
)
118118
for _ in range(int(response))
119119
]
120-
self.handle_push_response(response, disable_decoding, push_request)
120+
response = self.handle_push_response(
121+
response, disable_decoding, push_request
122+
)
121123
else:
122124
raise InvalidResponse(f"Protocol Error: {raw!r}")
123125

@@ -259,7 +261,9 @@ async def _read_response(
259261
)
260262
for _ in range(int(response))
261263
]
262-
await self.handle_push_response(response, disable_decoding, push_request)
264+
response = await self.handle_push_response(
265+
response, disable_decoding, push_request
266+
)
263267
else:
264268
raise InvalidResponse(f"Protocol Error: {raw!r}")
265269

0 commit comments

Comments
 (0)