Skip to content

Commit

Permalink
Fix pylint disallowed-name error in sanity tests
Browse files Browse the repository at this point in the history
  • Loading branch information
allenrobel committed Dec 21, 2023
1 parent f086735 commit bf09150
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
15 changes: 9 additions & 6 deletions plugins/module_utils/common/params_merge_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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

Expand All @@ -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)

Expand All @@ -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):
"""
Expand Down
8 changes: 4 additions & 4 deletions plugins/module_utils/common/params_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit bf09150

Please sign in to comment.