run pre-commit upgrade code for Py3.8+

This commit is contained in:
jeanluc 2023-06-21 21:20:45 +02:00 committed by Megan Wilhite
parent 7b0d09bd29
commit c81e8f045b
2 changed files with 22 additions and 22 deletions

View file

@ -86,9 +86,7 @@ def _get_top_file_envs():
else:
envs = "base"
except SaltRenderError as exc:
raise CommandExecutionError(
"Unable to render top file(s): {}".format(exc)
)
raise CommandExecutionError(f"Unable to render top file(s): {exc}")
__context__["saltutil._top_file_envs"] = envs
return envs
@ -164,7 +162,7 @@ def update(version=None):
try:
version = app.find_update()
except urllib.error.URLError as exc:
ret["_error"] = "Could not connect to update_url. Error: {}".format(exc)
ret["_error"] = f"Could not connect to update_url. Error: {exc}"
return ret
if not version:
ret["_error"] = "No updates available"
@ -172,21 +170,21 @@ def update(version=None):
try:
app.fetch_version(version)
except EskyVersionError as exc:
ret["_error"] = "Unable to fetch version {}. Error: {}".format(version, exc)
ret["_error"] = f"Unable to fetch version {version}. Error: {exc}"
return ret
try:
app.install_version(version)
except EskyVersionError as exc:
ret["_error"] = "Unable to install version {}. Error: {}".format(version, exc)
ret["_error"] = f"Unable to install version {version}. Error: {exc}"
return ret
try:
app.cleanup()
except Exception as exc: # pylint: disable=broad-except
ret["_error"] = "Unable to cleanup. Error: {}".format(exc)
ret["_error"] = f"Unable to cleanup. Error: {exc}"
restarted = {}
for service in __opts__["update_restart_services"]:
restarted[service] = __salt__["service.restart"](service)
ret["comment"] = "Updated from {} to {}".format(oldversion, version)
ret["comment"] = f"Updated from {oldversion} to {version}"
ret["restarted"] = restarted
return ret
@ -1154,7 +1152,9 @@ def sync_all(
ret["matchers"] = sync_matchers(saltenv, False, extmod_whitelist, extmod_blacklist)
if __opts__["file_client"] == "local":
ret["pillar"] = sync_pillar(saltenv, False, extmod_whitelist, extmod_blacklist)
ret["wrapper"] = sync_wrapper(saltenv, False, extmod_whitelist, extmod_blacklist)
ret["wrapper"] = sync_wrapper(
saltenv, False, extmod_whitelist, extmod_blacklist
)
if refresh:
# we don't need to call refresh_modules here because it's done by refresh_pillar
refresh_pillar(clean_cache=clean_pillar_cache)
@ -1452,7 +1452,7 @@ def find_cached_job(jid):
" enable cache_jobs on this minion"
)
else:
return "Local jobs cache directory {} not found".format(job_dir)
return f"Local jobs cache directory {job_dir} not found"
path = os.path.join(job_dir, "return.p")
with salt.utils.files.fopen(path, "rb") as fp_:
buf = fp_.read()
@ -1654,7 +1654,7 @@ def _exec(
kwarg,
batch=False,
subset=False,
**kwargs
**kwargs,
):
fcn_ret = {}
seen = 0
@ -1710,7 +1710,7 @@ def cmd(
ret="",
kwarg=None,
ssh=False,
**kwargs
**kwargs,
):
"""
.. versionchanged:: 2017.7.0
@ -1731,7 +1731,7 @@ def cmd(
# if return is empty, we may have not used the right conf,
# try with the 'minion relative master configuration counter part
# if available
master_cfgfile = "{}master".format(cfgfile[:-6]) # remove 'minion'
master_cfgfile = f"{cfgfile[:-6]}master" # remove 'minion'
if (
not fcn_ret
and cfgfile.endswith("{}{}".format(os.path.sep, "minion"))
@ -1754,7 +1754,7 @@ def cmd_iter(
ret="",
kwarg=None,
ssh=False,
**kwargs
**kwargs,
):
"""
.. versionchanged:: 2017.7.0

View file

@ -78,7 +78,7 @@ def test_sync(
"""
Ensure modules are synced when various sync functions are called
"""
module_name = "hello_sync_{}".format(module_type)
module_name = f"hello_sync_{module_type}"
module_contents = """
def __virtual__():
return "hello"
@ -87,17 +87,17 @@ def world():
return "world"
"""
test_moduledir = salt_master.state_tree.base.paths[0] / "_{}".format(module_type)
test_moduledir = salt_master.state_tree.base.paths[0] / f"_{module_type}"
test_moduledir.mkdir(parents=True, exist_ok=True)
module_tempfile = salt_master.state_tree.base.temp_file(
"_{}/{}.py".format(module_type, module_name), module_contents
f"_{module_type}/{module_name}.py", module_contents
)
with module_tempfile, test_moduledir:
salt_cmd = "saltutil.sync_{}".format(module_sync_functions[module_type])
salt_cmd = f"saltutil.sync_{module_sync_functions[module_type]}"
ret = salt_run_cli.run(salt_cmd)
assert ret.returncode == 0
assert "{}.hello".format(module_type) in ret.stdout
assert f"{module_type}.hello" in ret.stdout
def _write_module_dir_and_file(module_type, salt_minion, salt_master):
@ -113,11 +113,11 @@ def world():
return "world"
"""
test_moduledir = salt_master.state_tree.base.paths[0] / "_{}".format(module_type)
test_moduledir = salt_master.state_tree.base.paths[0] / f"_{module_type}"
test_moduledir.mkdir(parents=True, exist_ok=True)
module_tempfile = salt_master.state_tree.base.temp_file(
"_{}/{}.py".format(module_type, module_name), module_contents
f"_{module_type}/{module_name}.py", module_contents
)
return module_tempfile
@ -141,4 +141,4 @@ def test_sync_all(salt_run_cli, salt_minion, salt_master):
assert ret.returncode == 0
for module_type in get_module_types():
assert "{}.hello".format(module_type) in ret.stdout
assert f"{module_type}.hello" in ret.stdout