From bf09150a24909646638aef35d43a0e2dbfead245 Mon Sep 17 00:00:00 2001 From: Allen Robel Date: Thu, 21 Dec 2023 13:29:31 -1000 Subject: [PATCH] Fix pylint disallowed-name error in sanity tests --- .../module_utils/common/params_merge_defaults.py | 15 +++++++++------ plugins/module_utils/common/params_validate.py | 8 ++++---- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/plugins/module_utils/common/params_merge_defaults.py b/plugins/module_utils/common/params_merge_defaults.py index bc08a5337..4941eab50 100644 --- a/plugins/module_utils/common/params_merge_defaults.py +++ b/plugins/module_utils/common/params_merge_defaults.py @@ -33,6 +33,7 @@ class ParamsMergeDefaults: associated with them into parameters (if parameters is missing the corresponding key/value). """ + def __init__(self, ansible_module): self.class_name = self.__class__.__name__ self.ansible_module = ansible_module @@ -71,9 +72,8 @@ def _build_reserved_params(self): self.reserved_params.add("preferred_type") def _merge_default_params( - self, - spec: Dict[str, Any], - params: Dict[str, Any]) -> Dict[str, Any]: + self, spec: Dict[str, Any], params: Dict[str, Any] + ) -> Dict[str, Any]: """ Merge default parameters into parameters. @@ -87,7 +87,6 @@ def _merge_default_params( method_name = inspect.stack()[0][3] # pylint: disable=unused-variable for spec_key, spec_value in spec.items(): - if spec_key in self.reserved_params: continue @@ -98,7 +97,9 @@ def _merge_default_params( continue if isinstance(spec_value, Map): - params[spec_key] = self._merge_default_params(spec_value, params[spec_key]) + params[spec_key] = self._merge_default_params( + spec_value, params[spec_key] + ) return copy.deepcopy(params) @@ -120,7 +121,9 @@ def commit(self) -> None: msg += "Cannot commit. parameters is None." self.ansible_module.fail_json(msg) - self.properties["merged_parameters"] = self._merge_default_params(self.params_spec, self.parameters) + self.properties["merged_parameters"] = self._merge_default_params( + self.params_spec, self.parameters + ) def log_msg(self, msg): """ diff --git a/plugins/module_utils/common/params_validate.py b/plugins/module_utils/common/params_validate.py index 47e71b266..f5ef4ad1d 100644 --- a/plugins/module_utils/common/params_validate.py +++ b/plugins/module_utils/common/params_validate.py @@ -498,7 +498,7 @@ def _validate_ipv4_address(value: Any) -> Any: verify that value is an IPv4 address """ try: - _ = ipaddress.IPv4Address(value) + ipaddress.IPv4Address(value) return value except ipaddress.AddressValueError as err: raise ValueError(f"invalid IPv4 address: {err}") from err @@ -509,7 +509,7 @@ def _validate_ipv4_subnet(value: Any) -> Any: verify that value is an IPv4 network """ try: - _ = ipaddress.IPv4Network(value) + ipaddress.IPv4Network(value) return value except ipaddress.AddressValueError as err: raise ValueError(f"invalid IPv4 network: {err}") from err @@ -520,7 +520,7 @@ def _validate_ipv6_address(value: Any) -> Any: verify that value is an IPv6 address """ try: - _ = ipaddress.IPv6Address(value) + ipaddress.IPv6Address(value) return value except ipaddress.AddressValueError as err: raise ValueError(f"invalid IPv6 address: {err}") from err @@ -531,7 +531,7 @@ def _validate_ipv6_subnet(value: Any) -> Any: verify that value is an IPv6 network """ try: - _ = ipaddress.IPv6Network(value) + ipaddress.IPv6Network(value) return value except ipaddress.AddressValueError as err: raise ValueError(f"invalid IPv6 network: {err}") from err