mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
fix ruff case SIM110 (#11215)
* fix ruff case SIM110 * Update plugins/module_utils/xenserver.py Co-authored-by: Felix Fontein <felix@fontein.de> * add changelog frag --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
d364e35423
commit
862fe79a22
16 changed files with 34 additions and 72 deletions
|
|
@ -159,11 +159,7 @@ def is_input_dangerous(string):
|
|||
if not string:
|
||||
return False
|
||||
|
||||
for pattern in (PATTERN_1, PATTERN_2, PATTERN_3):
|
||||
if re.search(pattern, string):
|
||||
return True
|
||||
|
||||
return False
|
||||
return any(pattern.search(string) for pattern in (PATTERN_1, PATTERN_2, PATTERN_3))
|
||||
|
||||
|
||||
def check_input(module, *args):
|
||||
|
|
|
|||
|
|
@ -269,11 +269,7 @@ class _DictComparison:
|
|||
if set(dict1.keys()) != set(dict2.keys()):
|
||||
return False
|
||||
|
||||
for k in dict1:
|
||||
if not self._compare_value(dict1.get(k), dict2.get(k)):
|
||||
return False
|
||||
|
||||
return True
|
||||
return all(self._compare_value(dict1[k], dict2[k]) for k in dict1)
|
||||
|
||||
def _compare_lists(self, list1, list2):
|
||||
"""Takes in two lists and compares them."""
|
||||
|
|
@ -283,11 +279,7 @@ class _DictComparison:
|
|||
if len(list1) != len(list2):
|
||||
return False
|
||||
|
||||
for i in range(len(list1)):
|
||||
if not self._compare_value(list1[i], list2[i]):
|
||||
return False
|
||||
|
||||
return True
|
||||
return all(self._compare_value(l1, l2) for l1, l2 in zip(list1, list2))
|
||||
|
||||
def _compare_value(self, value1, value2):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -32,10 +32,7 @@ def is_ssh_url(url):
|
|||
|
||||
if "@" in url and "://" not in url:
|
||||
return True
|
||||
for scheme in "ssh://", "git+ssh://", "ssh+git://":
|
||||
if url.startswith(scheme):
|
||||
return True
|
||||
return False
|
||||
return any(url.startswith(scheme) for scheme in ("ssh://", "git+ssh://", "ssh+git://"))
|
||||
|
||||
|
||||
def get_fqdn_and_port(repo_url):
|
||||
|
|
|
|||
|
|
@ -507,10 +507,7 @@ def is_dictionary_subset(sub, super_dict):
|
|||
:param super_dict: super dictionary, for example resources_attr_value.
|
||||
:return: True if sub is contained in super.
|
||||
"""
|
||||
for key in sub:
|
||||
if sub[key] != super_dict[key]:
|
||||
return False
|
||||
return True
|
||||
return all(sub[key] == super_dict[key] for key in sub)
|
||||
|
||||
|
||||
def are_lists_equal(s, t):
|
||||
|
|
@ -533,10 +530,7 @@ def are_lists_equal(s, t):
|
|||
# `service_id` is provided by the user in the update call.
|
||||
sorted_s = sort_list_of_dictionary(s)
|
||||
sorted_t = sort_list_of_dictionary(t)
|
||||
for index, d in enumerate(sorted_s):
|
||||
if not is_dictionary_subset(d, sorted_t[index]):
|
||||
return False
|
||||
return True
|
||||
return all(is_dictionary_subset(d, sorted_t[index]) for index, d in enumerate(sorted_s))
|
||||
else:
|
||||
# Handle lists of primitive types.
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -230,7 +230,4 @@ class UTM:
|
|||
:param result: The result from the query
|
||||
:return:
|
||||
"""
|
||||
for key in keys:
|
||||
if module.params.get(key) != result[key]:
|
||||
return True
|
||||
return False
|
||||
return any(module.params.get(key) != result[key] for key in keys)
|
||||
|
|
|
|||
|
|
@ -219,11 +219,7 @@ def is_valid_ip6_addr(ip6_addr):
|
|||
|
||||
ip6_addr_hextet_regex = re.compile("^[0-9a-f]{1,4}$")
|
||||
|
||||
for ip6_addr_hextet in ip6_addr_split:
|
||||
if not bool(ip6_addr_hextet_regex.match(ip6_addr_hextet)):
|
||||
return False
|
||||
|
||||
return True
|
||||
return all(ip6_addr_hextet_regex.match(ip6_addr_hextet) for ip6_addr_hextet in ip6_addr_split)
|
||||
|
||||
|
||||
def is_valid_ip6_prefix(ip6_prefix):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue