1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

refactor: remove unneeded to_native calls (#477)

##### SUMMARY

Since we only support python >=3.8, the `to_native` python2/3
compatibility function is not needed anymore. We only keep it for
printing a traceback free exception message. Where a type conversion is
needed, we use the built-in `str()` function.
This commit is contained in:
Jonas L 2024-03-27 14:11:30 +01:00 committed by GitHub
parent 64f7824cc8
commit 4bb02b9cd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 394 additions and 453 deletions

View file

@ -168,7 +168,6 @@ hcloud_primary_ip:
"""
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_native
from ..module_utils.hcloud import AnsibleHCloud
from ..module_utils.vendor.hcloud import HCloudException
@ -182,19 +181,17 @@ class AnsibleHCloudPrimaryIP(AnsibleHCloud):
def _prepare_result(self):
return {
"id": to_native(self.hcloud_primary_ip.id),
"name": to_native(self.hcloud_primary_ip.name),
"ip": to_native(self.hcloud_primary_ip.ip),
"type": to_native(self.hcloud_primary_ip.type),
"datacenter": to_native(self.hcloud_primary_ip.datacenter.name),
"id": str(self.hcloud_primary_ip.id),
"name": self.hcloud_primary_ip.name,
"ip": self.hcloud_primary_ip.ip,
"type": self.hcloud_primary_ip.type,
"datacenter": self.hcloud_primary_ip.datacenter.name,
"labels": self.hcloud_primary_ip.labels,
"delete_protection": self.hcloud_primary_ip.protection["delete"],
"assignee_id": (
to_native(self.hcloud_primary_ip.assignee_id)
if self.hcloud_primary_ip.assignee_id is not None
else None
str(self.hcloud_primary_ip.assignee_id) if self.hcloud_primary_ip.assignee_id is not None else None
),
"assignee_type": to_native(self.hcloud_primary_ip.assignee_type),
"assignee_type": self.hcloud_primary_ip.assignee_type,
"auto_delete": self.hcloud_primary_ip.auto_delete,
}