Skip to content

Commit

Permalink
Remove redundant dict.keys() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
pederhan committed Sep 4, 2024
1 parent 891fdd7 commit c62ccfc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions zabbix_auto_config/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,8 +1185,8 @@ def do_update(self) -> None:
else:
zabbix_managed_hosts.append(host)

db_hostnames = set(db_hosts.keys())
zabbix_hostnames = set(zabbix_hosts.keys())
db_hostnames = set(db_hosts)
zabbix_hostnames = set(zabbix_hosts)
zabbix_managed_hostnames = {host.host for host in zabbix_managed_hosts}
zabbix_manual_hostnames = {host.host for host in zabbix_manual_hosts}

Expand Down Expand Up @@ -1486,7 +1486,7 @@ def do_update(self) -> None:
zabbix_templates[zabbix_template.host] = zabbix_template

managed_template_names = managed_template_names.intersection(
set(zabbix_templates.keys())
set(zabbix_templates)
) # If the template isn't in zabbix we can't manage it

# Get hosts from DB
Expand Down Expand Up @@ -1536,7 +1536,7 @@ def do_update(self) -> None:
host_templates_to_remove: Dict[str, Template] = {}

# Update templates on host
for template_name in list(host_templates.keys()):
for template_name in list(host_templates):
if (
template_name in managed_template_names
and template_name not in synced_template_names
Expand All @@ -1551,7 +1551,7 @@ def do_update(self) -> None:
]
del host_templates[template_name]
for template_name in synced_template_names:
if template_name not in host_templates.keys():
if template_name not in host_templates:
logging.debug(
"Going to add template '%s' to host '%s'.",
template_name,
Expand Down Expand Up @@ -1798,7 +1798,7 @@ def do_update(self) -> None:
host_hostgroups[zabbix_hostgroup.name] = zabbix_hostgroup
old_host_hostgroups = host_hostgroups.copy()

for hostgroup_name in list(host_hostgroups.keys()):
for hostgroup_name in list(host_hostgroups):
# TODO: Here lies a bug due to managed_hostgroup_names not being properly updated above?
# NOTE (pederhan): Not sure what this refers to?
if (
Expand Down

0 comments on commit c62ccfc

Please sign in to comment.