From 4de9c8356b95f4b8421d7be1de4e8d7f49f8c5b9 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Mon, 2 Feb 2026 13:57:04 -0500 Subject: [PATCH] Use fromkeys for constant * https://sonarcloud.io/project/issues?open=AZeD0GsJyrLLb-kZUOoF&id=ansible_awx --- awx/api/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 9ea01586c2..ab5703d9c8 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -2165,13 +2165,13 @@ class BulkHostDeleteSerializer(serializers.Serializer): attrs['hosts_data'] = attrs['host_qs'].values() if len(attrs['host_qs']) == 0: - error_hosts = {host: "Hosts do not exist or you lack permission to delete it" for host in attrs['hosts']} + error_hosts = dict.fromkeys(attrs['hosts'], "Hosts do not exist or you lack permission to delete it") raise serializers.ValidationError({'hosts': error_hosts}) if len(attrs['host_qs']) < len(attrs['hosts']): hosts_exists = [host['id'] for host in attrs['hosts_data']] failed_hosts = list(set(attrs['hosts']).difference(hosts_exists)) - error_hosts = {host: "Hosts do not exist or you lack permission to delete it" for host in failed_hosts} + error_hosts = dict.fromkeys(failed_hosts, "Hosts do not exist or you lack permission to delete it") raise serializers.ValidationError({'hosts': error_hosts}) # Getting all inventories that the hosts can be in