From 76a86f765d9c78d55fd188c20631a4c118ed9b85 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 16 Feb 2024 07:22:49 +0000 Subject: [PATCH] Run `pyupgrade` against the files modified in the merge-forward --- salt/modules/hashutil.py | 6 ++---- salt/utils/crypt.py | 6 ++---- tests/unit/utils/test_process.py | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/salt/modules/hashutil.py b/salt/modules/hashutil.py index 926d385aa4f..9e834794e4e 100644 --- a/salt/modules/hashutil.py +++ b/salt/modules/hashutil.py @@ -39,7 +39,7 @@ def digest(instr, checksum="md5"): if hash_func is None: raise salt.exceptions.CommandExecutionError( - "Hash func '{}' is not supported.".format(checksum) + f"Hash func '{checksum}' is not supported." ) return hash_func(instr) @@ -63,9 +63,7 @@ def digest_file(infile, checksum="md5"): salt '*' hashutil.digest_file /path/to/file """ if not __salt__["file.file_exists"](infile): - raise salt.exceptions.CommandExecutionError( - "File path '{}' not found.".format(infile) - ) + raise salt.exceptions.CommandExecutionError(f"File path '{infile}' not found.") with salt.utils.files.fopen(infile, "rb") as f: file_hash = __salt__["hashutil.digest"](f.read(), checksum) diff --git a/salt/utils/crypt.py b/salt/utils/crypt.py index 3f9c5955915..e34576c175a 100644 --- a/salt/utils/crypt.py +++ b/salt/utils/crypt.py @@ -111,9 +111,7 @@ def decrypt( rend_func = renderers.get(rend) if rend_func is None: - raise SaltInvocationError( - "Decryption renderer '{}' is not available".format(rend) - ) + raise SaltInvocationError(f"Decryption renderer '{rend}' is not available") return rend_func(data, translate_newlines=translate_newlines) @@ -159,7 +157,7 @@ def pem_finger(path=None, key=None, sum_type="sha256"): for ind, _ in enumerate(pre): if ind % 2: # Is odd - finger += "{}:".format(pre[ind]) + finger += f"{pre[ind]}:" else: finger += pre[ind] return finger.rstrip(":") diff --git a/tests/unit/utils/test_process.py b/tests/unit/utils/test_process.py index f39d44add7a..2d7f7634d8b 100644 --- a/tests/unit/utils/test_process.py +++ b/tests/unit/utils/test_process.py @@ -42,7 +42,7 @@ def die(func): name = func.__name__[5:] def _die(): - salt.utils.process.appendproctitle("test_{}".format(name)) + salt.utils.process.appendproctitle(f"test_{name}") attrname = "die_" + name setattr(self, attrname, _die) @@ -62,7 +62,7 @@ def incr(func): name = func.__name__[5:] def _incr(counter, num): - salt.utils.process.appendproctitle("test_{}".format(name)) + salt.utils.process.appendproctitle(f"test_{name}") for _ in range(0, num): counter.value += 1 @@ -84,7 +84,7 @@ def spin(func): name = func.__name__[5:] def _spin(): - salt.utils.process.appendproctitle("test_{}".format(name)) + salt.utils.process.appendproctitle(f"test_{name}") while True: time.sleep(1)