mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
use f-strings in module utils (#10901)
* use f-strings in module utils * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * remove unused imports --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
@@ -38,7 +38,7 @@ def module_fails_on_exception(func):
|
||||
@wraps(func)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
def fix_key(k):
|
||||
return k if k not in conflict_list else "_" + k
|
||||
return k if k not in conflict_list else f"_{k}"
|
||||
|
||||
def fix_var_conflicts(output):
|
||||
result = {fix_key(k): v for k, v in output.items()}
|
||||
@@ -56,7 +56,7 @@ def module_fails_on_exception(func):
|
||||
except Exception as e:
|
||||
# patchy solution to resolve conflict with output variables
|
||||
output = fix_var_conflicts(self.output)
|
||||
msg = "Module failed with exception: {0}".format(str(e).strip())
|
||||
msg = f"Module failed with exception: {str(e).strip()}"
|
||||
self.module.fail_json(msg=msg, exception=traceback.format_exc(),
|
||||
output=self.output, vars=self.vars.output(), **output)
|
||||
return wrapper
|
||||
|
||||
Reference in New Issue
Block a user