Skip to content

Commit

Permalink
Fix pre-commit
Browse files Browse the repository at this point in the history
Signed-off-by: Roald Nefs <[email protected]>
  • Loading branch information
roaldnefs authored and dwoz committed Dec 17, 2023
1 parent 8dc4160 commit 60b890b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
File renamed without changes.
14 changes: 7 additions & 7 deletions salt/returners/redis_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def returner(ret):
serv = _get_serv(ret)
pipeline = serv.pipeline(transaction=False)
minion, jid = ret["id"], ret["jid"]
pipeline.hset("ret:{}".format(jid), minion, salt.utils.json.dumps(ret))
pipeline.expire("ret:{}".format(jid), _get_ttl())
pipeline.hset(f"ret:{jid}", minion, salt.utils.json.dumps(ret))
pipeline.expire(f"ret:{jid}", _get_ttl())
pipeline.set("{}:{}".format(minion, ret["fun"]), jid)
pipeline.sadd("minions", minion)
pipeline.execute()
Expand All @@ -229,7 +229,7 @@ def save_load(jid, load, minions=None):
Save the load to the specified jid
"""
serv = _get_serv(ret=None)
serv.setex("load:{}".format(jid), _get_ttl(), salt.utils.json.dumps(load))
serv.setex(f"load:{jid}", _get_ttl(), salt.utils.json.dumps(load))


def save_minions(jid, minions, syndic_id=None): # pylint: disable=unused-argument
Expand All @@ -243,7 +243,7 @@ def get_load(jid):
Return the load data that marks a specified jid
"""
serv = _get_serv(ret=None)
data = serv.get("load:{}".format(jid))
data = serv.get(f"load:{jid}")
if data:
return salt.utils.json.loads(data)
return {}
Expand All @@ -255,7 +255,7 @@ def get_jid(jid):
"""
serv = _get_serv(ret=None)
ret = {}
for minion, data in serv.hgetall("ret:{}".format(jid)).items():
for minion, data in serv.hgetall(f"ret:{jid}").items():
if data:
ret[minion] = salt.utils.json.loads(data)
return ret
Expand All @@ -268,14 +268,14 @@ def get_fun(fun):
serv = _get_serv(ret=None)
ret = {}
for minion in serv.smembers("minions"):
ind_str = "{}:{}".format(minion, fun)
ind_str = f"{minion}:{fun}"
try:
jid = serv.get(ind_str)
except Exception: # pylint: disable=broad-except
continue
if not jid:
continue
data = serv.get("{}:{}".format(minion, jid))
data = serv.get(f"{minion}:{jid}")
if data:
ret[minion] = salt.utils.json.loads(data)
return ret
Expand Down
1 change: 1 addition & 0 deletions tests/pytests/unit/returners/test_redis_return.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

import salt.returners.redis_return as redis_return
from tests.support.helpers import patch

Expand Down

0 comments on commit 60b890b

Please sign in to comment.