From 1d79f9bb2b0ba29e979af60c0bcbdfd3225ba6b1 Mon Sep 17 00:00:00 2001 From: Teal Dulcet Date: Sat, 23 Dec 2023 05:40:37 -0800 Subject: [PATCH] Fixed PERF401 (manual-list-comprehension): Use a list comprehension to create a transformed list --- management/dns_update.py | 10 +++------- management/mail_log.py | 5 +---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/management/dns_update.py b/management/dns_update.py index 5e24f118..597df243 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -49,9 +49,7 @@ def get_dns_zones(env): zone_domains.add(domain) # Make a nice and safe filename for each domain. - zonefiles = [] - for domain in zone_domains: - zonefiles.append([domain, safe_domain_name(domain) + ".txt"]) + zonefiles = [[domain, safe_domain_name(domain) + ".txt"] for domain in zone_domains] # Sort the list so that the order is nice and so that nsd.conf has a # stable order so we don't rewrite the file & restart the service @@ -195,8 +193,7 @@ def build_zone(domain, domain_properties, additional_records, env, is_zone=True) # User may provide one or more additional nameservers secondary_ns_list = get_secondary_dns(additional_records, mode="NS") \ or ["ns2." + env["PRIMARY_HOSTNAME"]] - for secondary_ns in secondary_ns_list: - records.append((None, "NS", secondary_ns+'.', False)) + records.extend((None, "NS", secondary_ns+'.', False) for secondary_ns in secondary_ns_list) # In PRIMARY_HOSTNAME... @@ -213,8 +210,7 @@ def build_zone(domain, domain_properties, additional_records, env, is_zone=True) records.append(("_443._tcp", "TLSA", build_tlsa_record(env), "Optional. When DNSSEC is enabled, provides out-of-band HTTPS certificate validation for a few web clients that support it.")) # Add a SSHFP records to help SSH key validation. One per available SSH key on this system. - for value in build_sshfp_records(): - records.append((None, "SSHFP", value, "Optional. Provides an out-of-band method for verifying an SSH key before connecting. Use 'VerifyHostKeyDNS yes' (or 'VerifyHostKeyDNS ask') when connecting with ssh.")) + records.extend((None, "SSHFP", value, "Optional. Provides an out-of-band method for verifying an SSH key before connecting. Use 'VerifyHostKeyDNS yes' (or 'VerifyHostKeyDNS ask') when connecting with ssh.") for value in build_sshfp_records()) # Add DNS records for any subdomains of this domain. We should not have a zone for # both a domain and one of its subdomains. diff --git a/management/mail_log.py b/management/mail_log.py index 0c91365b..e127af3b 100755 --- a/management/mail_log.py +++ b/management/mail_log.py @@ -619,10 +619,7 @@ def print_time_table(labels, data, do_print=True): data.insert(0, [str(h) for h in range(24)]) temp = "│ {:<%d} " % max(len(l) for l in labels) - lines = [] - - for label in labels: - lines.append(temp.format(label)) + lines = [temp.format(label) for label in labels] for h in range(24): max_len = max(len(str(d[h])) for d in data)