[PR #8833/26df6c76 backport][stable-9] use dict comprehension in plugins, part 3 (#8835)

use dict comprehension in plugins, part 3 (#8833)

* use dict comprehension in plugins, part 3

* add changelog frag

(cherry picked from commit 26df6c7657)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2024-09-08 14:46:13 +02:00 committed by GitHub
parent 1978100d25
commit 186d410f63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 81 additions and 61 deletions

View file

@ -145,11 +145,11 @@ def ip_attributes_should_be_changed(api, target_ip, wished_ip):
def payload_from_wished_ip(wished_ip):
return dict(
(k, v)
return {
k: v
for k, v in wished_ip.items()
if k != 'id' and v is not None
)
}
def present_strategy(api, wished_ip):
@ -161,8 +161,7 @@ def present_strategy(api, wished_ip):
response.status_code, response.json['message']))
ips_list = response.json["ips"]
ip_lookup = dict((ip["id"], ip)
for ip in ips_list)
ip_lookup = {ip["id"]: ip for ip in ips_list}
if wished_ip["id"] not in ip_lookup.keys():
changed = True
@ -212,8 +211,7 @@ def absent_strategy(api, wished_ip):
api.module.fail_json(msg='Error getting IPs [{0}: {1}]'.format(
status_code, response.json['message']))
ip_lookup = dict((ip["id"], ip)
for ip in ips_list)
ip_lookup = {ip["id"]: ip for ip in ips_list}
if wished_ip["id"] not in ip_lookup.keys():
return changed, {}