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

refactor: add future annotations imports (#398)

##### SUMMARY

This adds future annotations imports to benefit from the modern python
typing system.
This commit is contained in:
Jonas L 2023-11-23 14:53:10 +01:00 committed by GitHub
parent 9905bd0e01
commit df8c3b6a59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 275 additions and 126 deletions

View file

@ -3,8 +3,10 @@
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
from __future__ import annotations
import traceback
from typing import Any, Dict, Optional, Union
from typing import Any
from ansible.module_utils.basic import (
AnsibleModule as AnsibleModuleBase,
@ -56,7 +58,7 @@ class AnsibleHCloud:
def fail_json_hcloud(
self,
exception: HCloudException,
msg: Optional[str] = None,
msg: str | None = None,
params: Any = None,
**kwargs,
) -> None:
@ -91,7 +93,7 @@ class AnsibleHCloud:
application_version=version,
)
def _client_get_by_name_or_id(self, resource: str, param: Union[str, int]):
def _client_get_by_name_or_id(self, resource: str, param: str | int):
"""
Get a resource by name, and if not found by its ID.
@ -132,11 +134,11 @@ class AnsibleHCloud:
},
}
def _prepare_result(self) -> Dict[str, Any]:
def _prepare_result(self) -> dict[str, Any]:
"""Prepare the result for every module"""
return {}
def get_result(self) -> Dict[str, Any]:
def get_result(self) -> dict[str, Any]:
if getattr(self, self.represent) is not None:
self.result[self.represent] = self._prepare_result()
return self.result