Use dict comprehension in plugins (#8814)

* use dict comprehension in plugins

* Apply suggestions from code review

* add changelog frag

* fix references in changelog frag
This commit is contained in:
Alexei Znamensky 2024-09-02 06:22:53 +12:00 committed by GitHub
parent 593d302f0b
commit ecc048bc12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 81 additions and 45 deletions

View file

@ -970,7 +970,7 @@ class ProxmoxKvmAnsible(ProxmoxAnsible):
self.module.fail_json(msg='Getting information for VM with vmid = %s failed with exception: %s' % (vmid, e))
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
kwargs = dict((k, v) for k, v in kwargs.items() if v is not None)
kwargs = {k: v for k, v in kwargs.items() if v is not None}
# Convert all dict in kwargs to elements.
# For hostpci[n], ide[n], net[n], numa[n], parallel[n], sata[n], scsi[n], serial[n], virtio[n]
@ -996,7 +996,7 @@ class ProxmoxKvmAnsible(ProxmoxAnsible):
proxmox_node = self.proxmox_api.nodes(node)
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
kwargs = dict((k, v) for k, v in kwargs.items() if v is not None)
kwargs = {k: v for k, v in kwargs.items() if v is not None}
return proxmox_node.qemu(vmid).config.set(**kwargs) is None
@ -1031,7 +1031,7 @@ class ProxmoxKvmAnsible(ProxmoxAnsible):
proxmox_node = self.proxmox_api.nodes(node)
# Sanitize kwargs. Remove not defined args and ensure True and False converted to int.
kwargs = dict((k, v) for k, v in kwargs.items() if v is not None)
kwargs = {k: v for k, v in kwargs.items() if v is not None}
kwargs.update(dict([k, int(v)] for k, v in kwargs.items() if isinstance(v, bool)))
version = self.version()