From 9f3424696078e527e4493a82884324f8bc811482 Mon Sep 17 00:00:00 2001 From: jeanluc Date: Fri, 17 Nov 2023 14:17:20 +0100 Subject: [PATCH] Run pre-commit after base change --- salt/client/ssh/wrapper/config.py | 4 ++-- salt/client/ssh/wrapper/cp.py | 2 +- salt/client/ssh/wrapper/slsutil.py | 8 ++++---- tests/pytests/unit/client/ssh/wrapper/test_cp.py | 14 +++++--------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/salt/client/ssh/wrapper/config.py b/salt/client/ssh/wrapper/config.py index 7dd3a7aa463..a6db176453c 100644 --- a/salt/client/ssh/wrapper/config.py +++ b/salt/client/ssh/wrapper/config.py @@ -498,10 +498,10 @@ def dot_vals(value): """ ret = {} for key, val in __pillar__.get("master", {}).items(): - if key.startswith("{}.".format(value)): + if key.startswith(f"{value}."): ret[key] = val for key, val in __opts__.items(): - if key.startswith("{}.".format(value)): + if key.startswith(f"{value}."): ret[key] = val return ret diff --git a/salt/client/ssh/wrapper/cp.py b/salt/client/ssh/wrapper/cp.py index e888ce7203b..111eab1ae39 100644 --- a/salt/client/ssh/wrapper/cp.py +++ b/salt/client/ssh/wrapper/cp.py @@ -816,7 +816,7 @@ def _render_filenames(path, dest, saltenv, template, **kw): # render the path as a template using path_template_engine as the engine if template not in salt.utils.templates.TEMPLATE_REGISTRY: raise CommandExecutionError( - "Attempted to render file paths with unavailable engine {}".format(template) + f"Attempted to render file paths with unavailable engine {template}" ) kwargs = {} diff --git a/salt/client/ssh/wrapper/slsutil.py b/salt/client/ssh/wrapper/slsutil.py index e09ca1c2984..586d09ad2d6 100644 --- a/salt/client/ssh/wrapper/slsutil.py +++ b/salt/client/ssh/wrapper/slsutil.py @@ -173,7 +173,7 @@ def renderer(path=None, string=None, default_renderer="jinja|yaml", **kwargs): default_renderer, __opts__["renderer_blacklist"], __opts__["renderer_whitelist"], - **kwargs + **kwargs, ) return ret.read() if salt.utils.stringio.is_readable(ret) else ret @@ -185,12 +185,12 @@ def _get_serialize_fn(serializer, fn_name): if not fns: raise salt.exceptions.CommandExecutionError( - "Serializer '{}' not found.".format(serializer) + f"Serializer '{serializer}' not found." ) if not fn: raise salt.exceptions.CommandExecutionError( - "Serializer '{}' does not implement {}.".format(serializer, fn_name) + f"Serializer '{serializer}' does not implement {fn_name}." ) return fn @@ -419,7 +419,7 @@ def findup(startpath, filenames, saltenv="base"): # Verify the cwd is a valid path in the state tree if startpath and not path_exists(startpath, saltenv): raise salt.exceptions.SaltInvocationError( - "Starting path not found in the state tree: {}".format(startpath) + f"Starting path not found in the state tree: {startpath}" ) # Ensure that patterns is a string or list of strings diff --git a/tests/pytests/unit/client/ssh/wrapper/test_cp.py b/tests/pytests/unit/client/ssh/wrapper/test_cp.py index 502df3acc90..58f8334721c 100644 --- a/tests/pytests/unit/client/ssh/wrapper/test_cp.py +++ b/tests/pytests/unit/client/ssh/wrapper/test_cp.py @@ -202,7 +202,7 @@ def _setup(fs_root, cache_root): path = os.path.join(saltenv_root, "foo.txt") with salt.utils.files.fopen(path, "w") as fp_: - fp_.write("This is a test file in the '{}' saltenv.\n".format(saltenv)) + fp_.write(f"This is a test file in the '{saltenv}' saltenv.\n") (Path(saltenv_root) / "dirtofile").touch() (Path(saltenv_root) / "filetodir").mkdir() (Path(saltenv_root) / "filetodir" / "foo.sh").touch() @@ -235,7 +235,7 @@ def test_cache_dir(client, cache_root): Ensure entire directory is cached to correct location """ for saltenv in _saltenvs(): - assert client.cache_dir("salt://{}".format(SUBDIR), saltenv, cachedir=None) + assert client.cache_dir(f"salt://{SUBDIR}", saltenv, cachedir=None) for subdir_file in _subdir_files(): cache_loc = os.path.join( cache_root, @@ -282,9 +282,7 @@ def test_cache_dir_with_alternate_cachedir_and_absolute_path( alt_cachedir = os.path.join(tmp_path, "abs_cachedir") for saltenv in _saltenvs(): - assert client.cache_dir( - "salt://{}".format(SUBDIR), saltenv, cachedir=alt_cachedir - ) + assert client.cache_dir(f"salt://{SUBDIR}", saltenv, cachedir=alt_cachedir) for subdir_file in _subdir_files(): cache_loc = os.path.join( cache_root, @@ -326,9 +324,7 @@ def test_cache_dir_with_alternate_cachedir_and_relative_path(client, cache_root) alt_cachedir = "foo" for saltenv in _saltenvs(): - assert client.cache_dir( - "salt://{}".format(SUBDIR), saltenv, cachedir=alt_cachedir - ) + assert client.cache_dir(f"salt://{SUBDIR}", saltenv, cachedir=alt_cachedir) for subdir_file in _subdir_files(): cache_loc = os.path.join( cache_root, @@ -488,7 +484,7 @@ def test_cache_dest(client, cache_root): ) def _check(ret, expected): - assert ret == expected, "{} != {}".format(ret, expected) + assert ret == expected, f"{ret} != {expected}" _check(client.cache_dest(f"https://{relpath}"), _external())