Skip to content

Commit

Permalink
Run pre-commit after base change
Browse files Browse the repository at this point in the history
  • Loading branch information
lkubb committed Dec 29, 2023
1 parent 47a609f commit 4c15063
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions salt/client/ssh/wrapper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion salt/client/ssh/wrapper/cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
8 changes: 4 additions & 4 deletions salt/client/ssh/wrapper/slsutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def run():
default_renderer,
__opts__["renderer_blacklist"],
__opts__["renderer_whitelist"],
**kwargs
**kwargs,
)
return ret.read() if salt.utils.stringio.is_readable(ret) else ret

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 5 additions & 9 deletions tests/pytests/unit/client/ssh/wrapper/test_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _new_dir(path):

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()
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -488,7 +484,7 @@ def _salt(saltenv="base"):
)

def _check(ret, expected):
assert ret == expected, "{} != {}".format(ret, expected)
assert ret == expected, f"{ret} != {expected}"

_check(client.cache_dest(f"https://{relpath}"), _external())

Expand Down

0 comments on commit 4c15063

Please sign in to comment.