1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

modules g*: use f-strings (#10958)

* modules g*: use f-strings

* add changelog frag

* remove extraneous to_native()
This commit is contained in:
Alexei Znamensky 2025-10-25 11:54:38 +13:00 committed by GitHub
parent a3987c9844
commit b67e7c83cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 250 additions and 245 deletions

View file

@ -158,7 +158,6 @@ from datetime import datetime
from ansible.module_utils.api import basic_auth_argument_spec
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.general.plugins.module_utils.gitlab import (
auth_argument_spec, find_group, gitlab_authentication, gitlab
@ -187,7 +186,7 @@ class GitLabGroupAccessToken(object):
self.access_token_object = group.access_tokens.create(arguments)
changed = True
except (gitlab.exceptions.GitlabCreateError) as e:
self._module.fail_json(msg="Failed to create access token: %s " % to_native(e))
self._module.fail_json(msg=f"Failed to create access token: {e} ")
return changed
@ -213,7 +212,7 @@ class GitLabGroupAccessToken(object):
self.access_token_object.delete()
changed = True
except (gitlab.exceptions.GitlabCreateError) as e:
self._module.fail_json(msg="Failed to revoke access token: %s " % to_native(e))
self._module.fail_json(msg=f"Failed to revoke access token: {e} ")
return changed
@ -297,7 +296,7 @@ def main():
group = find_group(gitlab_instance, group_identifier)
if group is None:
module.fail_json(msg="Failed to create access token: group %s does not exists" % group_identifier)
module.fail_json(msg=f"Failed to create access token: group {group_identifier} does not exists")
gitlab_access_token_exists = False
gitlab_access_token.find_access_token(group, name)
@ -307,7 +306,7 @@ def main():
if state == 'absent':
if gitlab_access_token_exists:
gitlab_access_token.revoke_access_token()
module.exit_json(changed=True, msg="Successfully deleted access token %s" % name)
module.exit_json(changed=True, msg=f"Successfully deleted access token {name}")
else:
module.exit_json(changed=False, msg="Access token does not exists")