From 433687a4f9a9e1d1cdaa7d7e7a03c83005852065 Mon Sep 17 00:00:00 2001 From: melder Date: Tue, 6 Sep 2022 16:22:57 -0400 Subject: [PATCH] Fixes issue decode_responses is set to True regardless if REDIS_OM_URL environment variable is set. Otherwise these warnings pop up when persisting objects: Could not parse Redis response. Error was: "keywords must be strings". Probably, the connection is not set to decode responses from bytes. Attempting to decode response using the encoding set on model class (. Encoding: utf-8. --- aredis_om/connections.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aredis_om/connections.py b/aredis_om/connections.py index 37265a01..a8e693e2 100644 --- a/aredis_om/connections.py +++ b/aredis_om/connections.py @@ -7,13 +7,14 @@ def get_redis_connection(**kwargs) -> redis.Redis: + # Decode from UTF-8 by default + if "decode_responses" not in kwargs: + kwargs["decode_responses"] = True + # If someone passed in a 'url' parameter, or specified a REDIS_OM_URL # environment variable, we'll create the Redis client from the URL. url = kwargs.pop("url", URL) if url: return redis.Redis.from_url(url, **kwargs) - # Decode from UTF-8 by default - if "decode_responses" not in kwargs: - kwargs["decode_responses"] = True return redis.Redis(**kwargs)