mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Run pyupgrade
against the files modified in the merge-forward
This commit is contained in:
parent
967d3015f6
commit
6fb799d38a
3 changed files with 11 additions and 13 deletions
|
@ -146,7 +146,7 @@ def _module_dirs(
|
||||||
ext_type_types = []
|
ext_type_types = []
|
||||||
if ext_dirs:
|
if ext_dirs:
|
||||||
if ext_type_dirs is None:
|
if ext_type_dirs is None:
|
||||||
ext_type_dirs = "{}_dirs".format(tag)
|
ext_type_dirs = f"{tag}_dirs"
|
||||||
if ext_type_dirs in opts:
|
if ext_type_dirs in opts:
|
||||||
ext_type_types.extend(opts[ext_type_dirs])
|
ext_type_types.extend(opts[ext_type_dirs])
|
||||||
if ext_type_dirs and load_extensions is True:
|
if ext_type_dirs and load_extensions is True:
|
||||||
|
@ -246,7 +246,7 @@ def _module_dirs(
|
||||||
cli_module_dirs.insert(0, maybe_dir)
|
cli_module_dirs.insert(0, maybe_dir)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
maybe_dir = os.path.join(_dir, "_{}".format(ext_type))
|
maybe_dir = os.path.join(_dir, f"_{ext_type}")
|
||||||
if os.path.isdir(maybe_dir):
|
if os.path.isdir(maybe_dir):
|
||||||
cli_module_dirs.insert(0, maybe_dir)
|
cli_module_dirs.insert(0, maybe_dir)
|
||||||
|
|
||||||
|
@ -1212,7 +1212,7 @@ def grains(opts, force_refresh=False, proxy=None, context=None, loaded_base_name
|
||||||
import salt.modules.cmdmod
|
import salt.modules.cmdmod
|
||||||
|
|
||||||
# Make sure cache file isn't read-only
|
# Make sure cache file isn't read-only
|
||||||
salt.modules.cmdmod._run_quiet('attrib -R "{}"'.format(cfn))
|
salt.modules.cmdmod._run_quiet(f'attrib -R "{cfn}"')
|
||||||
with salt.utils.files.fopen(cfn, "w+b") as fp_:
|
with salt.utils.files.fopen(cfn, "w+b") as fp_:
|
||||||
try:
|
try:
|
||||||
salt.payload.dump(grains_data, fp_)
|
salt.payload.dump(grains_data, fp_)
|
||||||
|
|
|
@ -182,7 +182,7 @@ def _render_filenames(path, dest, saltenv, template, **kw):
|
||||||
# render the path as a template using path_template_engine as the engine
|
# render the path as a template using path_template_engine as the engine
|
||||||
if template not in salt.utils.templates.TEMPLATE_REGISTRY:
|
if template not in salt.utils.templates.TEMPLATE_REGISTRY:
|
||||||
raise CommandExecutionError(
|
raise CommandExecutionError(
|
||||||
"Attempted to render file paths with unavailable engine {}".format(template)
|
f"Attempted to render file paths with unavailable engine {template}"
|
||||||
)
|
)
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
|
|
@ -96,7 +96,7 @@ class AnsibleState:
|
||||||
for mod_name, mod_params in kwargs.items():
|
for mod_name, mod_params in kwargs.items():
|
||||||
args, kwargs = self.get_args(mod_params)
|
args, kwargs = self.get_args(mod_params)
|
||||||
try:
|
try:
|
||||||
ans_mod_out = __salt__["ansible.{}".format(mod_name)](
|
ans_mod_out = __salt__[f"ansible.{mod_name}"](
|
||||||
**{"__pub_arg": [args, kwargs]}
|
**{"__pub_arg": [args, kwargs]}
|
||||||
)
|
)
|
||||||
except Exception as err: # pylint: disable=broad-except
|
except Exception as err: # pylint: disable=broad-except
|
||||||
|
@ -170,7 +170,7 @@ def playbooks(name, rundir=None, git_repo=None, git_kwargs=None, ansible_kwargs=
|
||||||
ret = {
|
ret = {
|
||||||
"result": False,
|
"result": False,
|
||||||
"changes": {},
|
"changes": {},
|
||||||
"comment": "Running playbook {}".format(name),
|
"comment": f"Running playbook {name}",
|
||||||
"name": name,
|
"name": name,
|
||||||
}
|
}
|
||||||
if git_repo:
|
if git_repo:
|
||||||
|
@ -197,13 +197,13 @@ def playbooks(name, rundir=None, git_repo=None, git_kwargs=None, ansible_kwargs=
|
||||||
not check["changed"] and not check["failures"] and not check["unreachable"]
|
not check["changed"] and not check["failures"] and not check["unreachable"]
|
||||||
for check in checks["stats"].values()
|
for check in checks["stats"].values()
|
||||||
):
|
):
|
||||||
ret["comment"] = "No changes to be made from playbook {}".format(name)
|
ret["comment"] = f"No changes to be made from playbook {name}"
|
||||||
ret["result"] = True
|
ret["result"] = True
|
||||||
elif any(
|
elif any(
|
||||||
check["changed"] and not check["failures"] and not check["unreachable"]
|
check["changed"] and not check["failures"] and not check["unreachable"]
|
||||||
for check in checks["stats"].values()
|
for check in checks["stats"].values()
|
||||||
):
|
):
|
||||||
ret["comment"] = "Changes will be made from playbook {}".format(name)
|
ret["comment"] = f"Changes will be made from playbook {name}"
|
||||||
ret["result"] = None
|
ret["result"] = None
|
||||||
ret["changes"] = _changes(checks)
|
ret["changes"] = _changes(checks)
|
||||||
else:
|
else:
|
||||||
|
@ -224,7 +224,7 @@ def playbooks(name, rundir=None, git_repo=None, git_kwargs=None, ansible_kwargs=
|
||||||
not check["changed"] and not check["failures"] and not check["unreachable"]
|
not check["changed"] and not check["failures"] and not check["unreachable"]
|
||||||
for check in results["stats"].values()
|
for check in results["stats"].values()
|
||||||
):
|
):
|
||||||
ret["comment"] = "No changes to be made from playbook {}".format(name)
|
ret["comment"] = f"No changes to be made from playbook {name}"
|
||||||
ret["result"] = True
|
ret["result"] = True
|
||||||
ret["changes"] = _changes(results)
|
ret["changes"] = _changes(results)
|
||||||
else:
|
else:
|
||||||
|
@ -234,9 +234,7 @@ def playbooks(name, rundir=None, git_repo=None, git_kwargs=None, ansible_kwargs=
|
||||||
for check in results["stats"].values()
|
for check in results["stats"].values()
|
||||||
)
|
)
|
||||||
if ret["result"]:
|
if ret["result"]:
|
||||||
ret["comment"] = "Changes were made by playbook {}".format(name)
|
ret["comment"] = f"Changes were made by playbook {name}"
|
||||||
else:
|
else:
|
||||||
ret[
|
ret["comment"] = f"There were some issues running the playbook {name}"
|
||||||
"comment"
|
|
||||||
] = "There were some issues running the playbook {}".format(name)
|
|
||||||
return ret
|
return ret
|
||||||
|
|
Loading…
Add table
Reference in a new issue