Skip to content

Commit 82dadbf

Browse files
committed
added changelog,fix ruff
1 parent 7d8716d commit 82dadbf

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

changelog.d/749.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix is_master parsing error for write separation in sentinel mode

django_redis/client/default.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def expire(
328328

329329
# for some strange reason mypy complains,
330330
# saying that timeout type is float | timedelta
331-
return client.expire(key, timeout) # type: ignore
331+
return client.expire(key, timeout)
332332

333333
def pexpire(
334334
self,
@@ -349,7 +349,7 @@ def pexpire(
349349
# is fixed.
350350
# for some strange reason mypy complains,
351351
# saying that timeout type is float | timedelta
352-
return bool(client.pexpire(key, timeout)) # type: ignore
352+
return bool(client.pexpire(key, timeout))
353353

354354
def pexpire_at(
355355
self,

django_redis/client/herd.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def _is_expired(x, herd_timeout: int) -> bool:
2626
return True
2727
val = x + random.randint(1, herd_timeout)
2828

29-
if val >= herd_timeout:
30-
return True
31-
return False
29+
return val >= herd_timeout
3230

3331

3432
class HerdClient(DefaultClient):

django_redis/pool.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import Dict
2-
from urllib.parse import parse_qs, urlparse,urlencode,urlunparse
2+
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
33

44
from django.conf import settings
55
from django.core.exceptions import ImproperlyConfigured
@@ -168,26 +168,22 @@ def get_connection_pool(self, params):
168168
query_params = parse_qs(url.query)
169169
is_master = query_params.get("is_master")
170170
if is_master:
171-
cp_params['is_master'] = to_bool(is_master[0])
171+
cp_params["is_master"] = to_bool(is_master[0])
172172
# then remove the "is_master" query string from the URL
173173
# so it doesn't interfere with the SentinelConnectionPool constructor
174-
if 'is_master' in query_params:
175-
del query_params['is_master']
174+
if "is_master" in query_params:
175+
del query_params["is_master"]
176176
new_query = urlencode(query_params, doseq=True)
177177

178-
new_url = urlunparse((
179-
url.scheme,
180-
url.netloc,
181-
url.path,
182-
url.params,
183-
new_query,
184-
url.fragment
185-
))
178+
new_url = urlunparse(
179+
(url.scheme,url.netloc,url.path,url.params,new_query,url.fragment)
180+
)
186181

187-
cp_params.update(service_name=url.hostname, sentinel_manager=self._sentinel,url=new_url)
182+
cp_params.update(
183+
service_name=url.hostname, sentinel_manager=self._sentinel,url=new_url
184+
)
188185

189-
pool = super().get_connection_pool(cp_params)
190-
return pool
186+
return super().get_connection_pool(cp_params)
191187

192188

193189
def get_connection_factory(path=None, options=None):

0 commit comments

Comments
 (0)