Skip to content

Commit

Permalink
Fix implicit returns
Browse files Browse the repository at this point in the history
  • Loading branch information
whabanks committed Nov 6, 2024
1 parent a7fb0fa commit 3c896e9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions notifications_utils/clients/redis/redis_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ def delete_hash_fields(self, hashes: (str | list), fields: list = None, raise_ex
return result
except Exception as e:
self.__handle_exception(e, raise_exception, "expire_hash_fields", hashes)
else:
return False
return False

def bulk_set_hash_fields(self, mapping, pattern=None, key=None, raise_exception=False):
"""
Expand All @@ -135,9 +134,10 @@ def bulk_set_hash_fields(self, mapping, pattern=None, key=None, raise_exception=
for key in self.redis_store.scan_iter(pattern):
self.redis_store.hmset(key, mapping)
if key:
self.redis_store.hmset(key, mapping)
return self.redis_store.hmset(key, mapping)
except Exception as e:
self.__handle_exception(e, raise_exception, "bulk_set_hash_fields", pattern)
return False

def exceeded_rate_limit(self, cache_key, limit, interval, raise_exception=False):
"""
Expand Down Expand Up @@ -293,10 +293,12 @@ def set_hash_value(self, key, field, value, raise_exception=False):

if self.active:
try:
self.redis_store.hset(key, field, value)
return self.redis_store.hset(key, field, value)
except Exception as e:
self.__handle_exception(e, raise_exception, "set_hash_value", key)

return None

def decrement_hash_value(self, key, value, raise_exception=False):
return self.increment_hash_value(key, value, raise_exception, incr_by=-1)

Expand Down Expand Up @@ -331,6 +333,8 @@ def get_all_from_hash(self, key, raise_exception=False):
except Exception as e:
self.__handle_exception(e, raise_exception, "get_all_from_hash", key)

return None

def set_hash_and_expire(self, key, values, expire_in_seconds, raise_exception=False):
key = prepare_value(key)
values = {prepare_value(k): prepare_value(v) for k, v in values.items()}
Expand All @@ -341,6 +345,8 @@ def set_hash_and_expire(self, key, values, expire_in_seconds, raise_exception=Fa
except Exception as e:
self.__handle_exception(e, raise_exception, "set_hash_and_expire", key)

return None

def expire(self, key, expire_in_seconds, raise_exception=False):
key = prepare_value(key)
if self.active:
Expand Down

0 comments on commit 3c896e9

Please sign in to comment.