Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 6, 2024
1 parent 7d8716d commit f7d1ac0
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions django_redis/pool.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Dict
from urllib.parse import parse_qs, urlparse,urlencode,urlunparse
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
Expand Down Expand Up @@ -168,23 +168,20 @@ def get_connection_pool(self, params):
query_params = parse_qs(url.query)
is_master = query_params.get("is_master")
if is_master:
cp_params['is_master'] = to_bool(is_master[0])
cp_params["is_master"] = to_bool(is_master[0])

Check warning on line 171 in django_redis/pool.py

View check run for this annotation

Codecov / codecov/patch

django_redis/pool.py#L171

Added line #L171 was not covered by tests
# then remove the "is_master" query string from the URL
# so it doesn't interfere with the SentinelConnectionPool constructor
if 'is_master' in query_params:
del query_params['is_master']
if "is_master" in query_params:
del query_params["is_master"]

Check warning on line 175 in django_redis/pool.py

View check run for this annotation

Codecov / codecov/patch

django_redis/pool.py#L175

Added line #L175 was not covered by tests
new_query = urlencode(query_params, doseq=True)

new_url = urlunparse((
url.scheme,
url.netloc,
url.path,
url.params,
new_query,
url.fragment
))
new_url = urlunparse(
(url.scheme, url.netloc, url.path, url.params, new_query, url.fragment)
)

cp_params.update(service_name=url.hostname, sentinel_manager=self._sentinel,url=new_url)
cp_params.update(
service_name=url.hostname, sentinel_manager=self._sentinel, url=new_url
)

pool = super().get_connection_pool(cp_params)
return pool
Expand Down

0 comments on commit f7d1ac0

Please sign in to comment.