mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-27 14:08:53 +00:00
Add more type hints.
This commit is contained in:
parent
fe478bd1bb
commit
93cd3755a0
30 changed files with 354 additions and 298 deletions
|
|
@ -27,7 +27,7 @@ if t.TYPE_CHECKING:
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def _env_then_dns_fallback(*args, **kwargs):
|
||||
def _env_then_dns_fallback(*args, **kwargs) -> str:
|
||||
"""Load value from environment or DNS in that order"""
|
||||
try:
|
||||
result = env_fallback(*args, **kwargs)
|
||||
|
|
@ -54,10 +54,10 @@ class IPAClient:
|
|||
self.timeout = module.params.get("ipa_timeout")
|
||||
self.use_gssapi = False
|
||||
|
||||
def get_base_url(self):
|
||||
def get_base_url(self) -> str:
|
||||
return f"{self.protocol}://{self.host}/ipa"
|
||||
|
||||
def get_json_url(self):
|
||||
def get_json_url(self) -> str:
|
||||
return f"{self.get_base_url()}/session/json"
|
||||
|
||||
def login(self, username, password):
|
||||
|
|
@ -102,7 +102,7 @@ class IPAClient:
|
|||
{"referer": self.get_base_url(), "Content-Type": "application/json", "Accept": "application/json"}
|
||||
)
|
||||
|
||||
def _fail(self, msg, e):
|
||||
def _fail(self, msg: str, e) -> t.NoReturn:
|
||||
if "message" in e:
|
||||
err_string = e.get("message")
|
||||
else:
|
||||
|
|
@ -209,7 +209,7 @@ class IPAClient:
|
|||
return changed
|
||||
|
||||
|
||||
def ipa_argument_spec():
|
||||
def ipa_argument_spec() -> dict[str, t.Any]:
|
||||
return dict(
|
||||
ipa_prot=dict(type="str", default="https", choices=["http", "https"], fallback=(env_fallback, ["IPA_PROT"])),
|
||||
ipa_host=dict(type="str", default="ipa.example.com", fallback=(_env_then_dns_fallback, ["IPA_HOST"])),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue